JavaScript API Reference

Control

The following Instance Methods must be called on an instance of a ctrl object. This is a JavaScript control object, and is what you are creating.

As such, you can call these from your control's class methods using the this keyword.

Example

ctrl.myMethod = function() {
  var elem = this.getClientElem(); // "this" in this context is an instance of the ctrl_generic control.
} ;

There are also several Inherited Methods which you can implement your class to handle specific events.

Control – Inherited Methods

  

The following are inherited methods which you can implement in your control, in order to catch specific 'events'.

You can add such an inherited method as shown below:

<ctrl_name>.prototype.<method_name> = function() {
  //Custom code here
};

These are methods in the base class, which you are overriding.

If, in your handling of the 'event', you wish to fall back to default handling, you need to call the superclass version of the method, passing an instance of your control object, followed by the parameters you received.

Example

<ctrl_name>.prototype.<method_name> = function(p1, p2) {
  //Custom code here
  this.superclass.<method_name>.call(this, p1, p2 );
};

 

  

constructor

 All controls must have a constructor with no parameters.

The constructor is a static function, with the same name as your control.

The constructor should call your control's init_class_inst() method.

Parameters:

None

Example

function ctrl_generic() {
  this.init_class_inst(); // initialize our control
};

 

  

init_class_inst()

init_class_inst()

This initializes the class, and must be called by the constructor.

The default code should be left as is - it sets up the superclass.

Use this method to

Parameters:

None

Returns:

None

Example

ctrl.init_class_inst = function() {
  this.superclass = ctrl_base.prototype;
  this.superclass.init_class_inst.call( this ); // call our superclass class initializer
  this.myVar1 = 0;
};

 

 

init_ctrl_inst()

init_ctrl_inst(pForm, pElem, pRowCtrl, pRowNumber)

This is called after the control has been added to the page, with the content as set by the C++ side of your component’s jsGetInnerHTML() method.

This must begin by calling init_ctrl_inst() in the superclass.

Use this method to:

Parameters:

Returns:

Example

ctrl.init_ctrl_inst = function( form, elem, rowCtrl, rowNumber ) {
  this.superclass.init_ctrl_inst.call( this, form, elem, rowCtrl, rowNumber ); // call our superclass init_ctrl_inst
  //TODO: Control-specific initialization goes here
  return false;
};

 

 

delete_class_inst()

delete_class_inst()

This method is called when the object is removed, typically when a form is closed.

You should override this function if there is some work to do prior to your control being deleted.

Make sure to end your call to this by calling the superclass version.

Implement this method to:

Parameters:

None

Returns:

None

Example

ctrl.delete_class_inst = function() {
  // Custom cleanup code here.
  this.superclass.delete_class_inst.call(this); // Call superclass version to perform standard deletion procedure.
}

 

updateCtrl()

updateCtrl(pWhat, pRow, pCol, pMustUpdate)

This is called in when the control may need to be updated. Generally because the instance data variable has changed, ore something has occurred which necessitates an update.

You should use this method to update your control based on what has changed.

Note that there is no superclass version of this method, so you should not attempt to call the base class' implementation.

Implement this method to:

The parameters passed to this method only need to be handled if your control uses a list or row as its $dataname, and you wish to optimize your update code.

Parameters:

pMustUpdate is deprecated and may be removed in a future update. pWhat will perform the same functionality (when it is "", or otherwise 'falsey').

Returns:

None

Example

ctrl.updateCtrl = function(pWhat, pRow, pCol, pMustUpdate) {
  // Check if the $dataname variable has changed:
  if (pWhat == "") {
    this.curData = this.getData();
    this.rebuildMyControl(); // Custom method to rebuild control.
  }
};

 

 

handleEvent()

handleEvent(pEvent)

This is called when an event handler which was assigned this.mEventFunction is triggered.

Implement this method to:

Parameters:

Returns:

None

Example

ctrl.handleEvent = function( pEvent ) {
  switch (pEvent.type) {
    case "click":
      this.doMyClick(); // Handle the click
      jOmnis.stopEventNow(pEvent); // Prevent further propagation of this event.
      break;
    default:
      return this.superclass.handleEvent.call( this, pEvent ); // Let the base class handle other events
  }
};

 

getCanAssign()

getCanAssign(pPropNumber)

Use this method to create a switch statement which returns true or false as to whether the passed property can be assigned to, if it’s a custom property (or a base property you wish to treat differently). Otherwise, let the superclass handle it.

Implement this method to:

Parameters:

Returns:

Example

ctrl.getCanAssign = function(pPropNumber) {
  switch (pPropNumber) {
    case PROPERTIES.prop1:
      return true;
    default:
      return this.superclass.getCanAssign.call(this, pPropNumber); // Let base class handle other properties.
  }
};

 

getProperty()

getProperty(pPropNumber)

This is called when Omnis code attempts to get the value of a property of the control.

If it is a custom property (or a base property you need to use special handling for), you should catch and handle this yourself. Otherwise, let the superclass handle it.

The propNumbers of standard properties can be accessed via the eBaseProperties enumerated type.

It is good practice to call this method from your JavaScript code when you want to get the value of a property.

Implement this method to:

Parameters:

Returns:

Example

ctrl.getProperty = function(propNumber) {
  switch (propNumber) {
    case PROPERTIES.prop1:
      return this.mProp1;
    default:
      return this.superclass.getProperty.call(this, propNumber); // Let the base class handle other properties.
  }
};

 

setProperty()

setProperty(pPropNumber, pPropValue)

This is called when Omnis code attempts to set the value of a property of the control.

If it is a custom property, you should catch and handle this yourself. Otherwise, let the superclass handle it for default properties.

The propNumbers of standard properties can be accessed via the eBaseProperties enumerated type.

It is good practice to call this method from your JavaScript code when you want to set a property.

Implement this method to:

Parameters:

Returns:

Example

ctrl.setProperty = function( propNumber, propValue ) {
  if (!this.getCanAssign(propNumber))
    return false;
  switch (propNumber) {
    case eBaseProperties.enabled:
      this.handleEnabled(propValue);
      return true;
  default:
      return this.superclass.setProperty.call( this, propNumber, propValue ); // call our superclass setProperty for other properties
  }
};

 

 

sizeChanged()

sizeChanged()

Called when the size of the control has changed (e.g. due to a screen size change).

Implement this method to:

Parameters:

None

Returns:

None

Example

ctrl.sizeChanged = function() {
  // Custom code here
};

 

fillChanged()

fillChanged()

Called when the background of the control has changed due to a property change.

Implement this method to:

Parameters:

None

Returns:

None

Example

ctrl.fillChanged = function() {
  // Custom code here
};

 

fontChanged()

fontChanged()

Called when the font changes - either family, style or size.

Implement this method to:

Parameters:

None

Returns:

None

Example

ctrl.fontChanged = function() {
  // Custom code here
};

 

 

enabledChanged()

enabledChanged()

Called when $enabled has changed (and also when constructing the control).

If you implement this, you will probably want to get the current enabled state. You can use this.isEnabled() to return this.

Implement this method to:

Parameters:

None

Returns:

None

Example

ctrl.enabledChanged = function() {
  var state = this.isEnabled();
  // Custom code here
};

 

activeChanged()

activeChanged()

Called when $active has changed (and when constructing the control).

If you implement this, you will probably want to get the current active state. You can use this.isActive() to return this.

Implement this method to:

Parameters:

Returns:

Example:

ctrl.activeChanged = function() {
  var state = this.isActive();
  // Custom code here
};

 

getTrueVisibility()

getTrueVisibility(pChildCtrl)

Returns the true visibility state of the control, based on parent object and own visible property.

More complex controls may need to override this. If you do, it's recommended to first call the base class' implementation as this already does the work of checking parent controls and containing subforms' visibility.

Parameters:

Returns:

Example

ctrl.getTrueVisibility = function(pChildCtrl) {
  var visible = this.superclass.getTrueVisibility.call( this, childCtrl ); // call base class
  // If the base class thinks the control should be visible, check that no control-specific behaviour contradicts this:
  if (visible) {
    visible = this.reallyVisible();
  }
  return visible;
};

 

visibilityChanged()

visibilityChanged()

Called when the visibility of your control may have changed (e.g. it may be on a paged pane which is no longer visible).

Typically you would call the base class' implementation of this first, then add your own logic.

If the base class returns false, but you decide to return true in your own logic, you should also set the visibility css style of your control to the new value.

Implement this method to:

Parameters:

None

Returns:

Example

ctrl.visibilityChanged = function()
{
  var ret = this.superclass.visibilityChanged.call(this);
  if (ret)
    this.updateLayout();
    return ret;
}

 

formBuilt()

formBuilt()

If you called registerForFormBuilt() in your control, this method will be called when the rest of the form has finished constructing.

There is no superclass implementation of this method, so do not attempt to call one.

Parameters:

None

Returns:

None

Example

ctrl.formBuilt = function () {
  alert("The form has finished construction!");
}

 

getErrorBorderDiv()

getErrorBorderDiv()

When a control's $errortext is assigned to, it will show the error text around the control, and add a red border. By default, this border is drawn around the control's client element.

If this does not make sense for a control, it can override this method and return the element around which the error border should be drawn.

Parameters:

None

Returns:

Example

ctrl.getErrorBorderDiv = function() {
  return this.mMainElem;
}

scriptAvail()

scriptAvail()

Called when the client script for the form is available if the control was registered with the requestScriptAvailNotify() form method.

Parameters:

None

Returns:

None

Example

ctrl.scriptAvail = function() {
    // Call a client method of the control named "$myMethod".
    var methodName = jOmnis.getMethod(this, "$myMethod", -1);
    if (methodName)
        this[methodName]();
};

 

 

Control - Instance Methods

The following are method calls you can make on a ctrl instance (i.e. your JavaScript control).

 

alphaFromCssColor()

alphaFromCssColor(pCssColor)

Gets the alpha value (0-255) from the given CSS color string. 0 being fully transparent, and 255 being completely opaque.

Parameters:

Returns:

Example

var alpha = this.alphaFromCssColor("rgba(155,155,208,0.5)"); // alpha becomes 128

 

callMethod()

callMethod(pMethodName, ...)

Calls a method (custom or built-in) of your control. Can be:

If there is a method in the JavaScript control with the same name as an Omnis field method, the method of the JavaScript control will be called.

Parameters:

Returns:

Example

var ret = this.callMethod("myMethod","Dave",23); //Call the method "myMethod", passing "Dave" & 23 as arguments.

 

callMethodEx()

callMethodEx(pMethodName, pFlags, ...)

Calls a method (custom or built-in) of your control, with extra configuration flags. Can be:

If there is a method in the JavaScript control with the same name as an Omnis field method, the method of the JavaScript control will be called.

Parameters:

Returns:

Example

var ret = this.callMethodEx("myMethod", eDoMethodFlags.completionEvent | eDoMethodFlags.noOverlay, "Dave", 123);

 

canSendEvent()

canSendEvent(pEventCode)

Returns true if the given event is enabled for this control and it can be sent to the server(/client event).

Parameters:

Returns:

Example (Default event)

if (this.canSendEvent(eBaseEvent.evClick) {
    this.eventParamsAdd("pName","Ernie");
    this.eventParamsAdd("pAge", 52);
    this.eventParamsAdd("pOccupation", "Milkman");
    this.sendEvent(eBaseEvent.evClick); // Sends event with the 3 parameters defined above.
}

Example (Custom Event)

var eMyControlEvents = { "evThingOccurred": 5000, "evThingHappened": 5001}
if (this.canSendEvent(eMyControlEvents.evThingHappened) {
    this.eventParamsAdd("pName","Ernie");
    this.eventParamsAdd("pAge", 52);
    this.eventParamsAdd("pOccupation", "Milkman");
    this.sendEvent("evThingHappened"); // Sends event with the 3 parameters defined above.
}

 

doSetProperty()

doSetProperty(pPropNumber, pPropValue)

This is a wrapper for setProperty(), which instead adds the property to the current animation block, if possible (i.e. the property is supported for animations). If the property can't be animated, it will be assigned immediately.

See beginAnimations() and commitAnimations().

If you have overridden setProperty() in your control, this will also be called into at the appropriate time.

Parameters:

Returns:

Example

var formInst = this.form;
formInst.beginAnimations(1000, 4); // Begin animation block
this.doSetProperty(eBaseProperties.left, 300); // Add property change to animation block.
formInst.commitAnimations(); // Run the animations.

 

eventParamsAdd()

eventParamsAdd(pName, pValue)

Adds a parameter to the event parameter list.

Call this method for each event parameter prior to calling sendEvent, which will call the event, sending the parameters.

The parameter list is cleared once sendEvent() has been called.

Parameters:

Returns:

None

Example

this.eventParamsAdd("pName","Ernie");
this.eventParamsAdd("pAge", 52);
this.eventParamsAdd("pOccupation", "Milkman");
this.sendEvent(eBaseEvent.evClick); // Sends event with the 3 parameters defined above.

 

focus()

focus()

Sets the focus to the control's client element.

Parameters:

None

Returns:

None

Example

this.focus();

 

getCanAssign()

getCanAssign(pPropNumber)

Gets whether you are allowed to assign a new value to a property.

This method will typically be overridden in your JavaScript control, to handle any custom properties, but fall back to the base class' implementation for base properties.

Parameters:

Returns:

Example

var canDisable= this.getCanAssign(eBaseProperties.enabled)

 

getClientElem()

getClientElem()

Returns the client HTML element for this control.

Parameters:

None

Returns:

Example

var elem = this.getClientElem();

 

getData()

getData(pWhat, pRow, pCol, pAltDataIndex, pFmt, pFormatString)

Returns the data associated with the control (typically the control's $dataname instance variable).

All parameters are optional.

The parameters only apply if your control uses a list or row instance variable for its $dataname.

Parameters:

Returns:

Example

// Get the whole $dataname instance variable data:
var myFullData = this.getData();
// Get the current line from the $dataname list:
var curLine = this.getData("#L");
// Get the data from column 2 in row 3 of the $dataname list:
var myListCell = this.getData("", 3, 2);

 

setData()

setData(pNewData, pWhat, pRow, pCol, pFmt, pFormatString, pUpdateThis, pIgnorePager)

Sets the value of the variable assigned to this control's $dataname.

Parameters:

Returns:

Example

this.setData(newValue, ""); // Change the full contents of the $dataname variable to the contents of newValue.

 

getDisplayFormat()

getDisplayFormat(pForceNumber, pDateSubtype)

Gets the format string to use when formatting a number or date-time variable.

If the control's $dataname is a numeric type, this returns the number format.

If the control's $dataname is a date type, this returns the date-time format.

Parameters:

Returns:

Example

var dateFormat = this.getDisplayFormat(false);

 

getIconUrlFromImgSrc()

getIconUrlFromImgSrc(pElem)

Gets the URL to an image from the given element's src attribute. Typically, this would be an img element.

Parameters:

Returns:

Example

var imgURL = this.getIconUrlFromImgSrc(elem);

 

getIconUrlFromStyleUrl()

getIconUrlFromStyleUrl(pElem)

Returns the URL to the image specified in the element's background-image property, when specified in the format:

"url(<url to image>)"

Parameters:

Returns:

Example

// elem.backgroundImage = "url(images/myImage.png)"
var imgURL = this.getIconUrlFromStyleUrl(elem);
// imgURL becomes "images/myImage.png"

 

 

getProperty()

getProperty(pPropNumber)

Gets the value of the given Omnis property number.

This method will typically be overridden in your JavaScript control, to handle any custom properties, but fall back to the base class' implementation for base properties.

Parameters:

Returns:

Example

var textColor = this.getProperty(eBaseProperties.textcolor);

 

getTextWidthDiv()

getTextWidthDiv()

Returns a div element, suitable for measuring text width (i.e. a div which tightly wraps its content).

Make sure to remove the div once you are finished with it, using removeTextWidthDiv().

Parameters:

Returns:

Example

var divElement = this.getTextWidthDiv();
divElement.innerHTML = "my string"; // Inject the text into the div
var stringWidth = divElement.clientWidth; //Measure the width of the div
this.removeTextWidthDiv(divElement);

 

removeTextWidthDiv()

removeTextWidthDiv(pElem)

Called to remove the div used for measuring text width (obtained using getTextWidthDiv()).

Parameters:

Returns:

Example

var divElement = this.getTextWidthDiv();
divElement.innerHTML = "my string"; // Inject the text into the div
var stringWidth = divElement.clientWidth; //Measure the width of the div
this.removeTextWidthDiv(divElement);

 

getTrueVisibility()

getTrueVisibility(pChildControl)

Returns true visibility state of the control, based on parent object and own visible property.

More complex controls may need to override this.

Parameters:

Returns:

Example

var isVisible = this.getTrueVisibility(null);

 

isEnabled()

isEnabled()

Returns whether the control is enabled (based on its state, and the state of any container(s).

Parameters:

Returns:

Example

var enabled = this.isEnabled();

 

removeFromTabOrder()

removeFromTabOrder()

Removes the control from the tab order.

Prevents the user from tabbing into it.

Parameters:

Returns:

Example

this.removeFromTabOrder(); // Remove this control from the tab order.

 

sendEvent()

sendEvent(pEventCode)

Sends an event to the server (or the client executed event if it's set to execute on client).

This function will send and clear the parameter list.

You would typically check canSendEvent() before calling this.

Parameters can be added to the event using eventParamsAdd().

Parameters:

Returns:

Example (Default event)

if (this.canSendEvent(eBaseEvent.evClick) {
  this.eventParamsAdd("pName","Ernie");
  this.eventParamsAdd("pAge", 52);
  this.eventParamsAdd("pOccupation", "Milkman");
  this.sendEvent(eBaseEvent.evClick); // Sends event with the 3 parameters defined above.
}

Example (Custom Event)

var eMyControlEvents = { "evThingOccurred": 5000, "evThingHappened": 5001}
if (this.canSendEvent(eMyControlEvents.evThingHappened) {
  this.eventParamsAdd("pName","Ernie");
  this.eventParamsAdd("pAge", 52);
  this.eventParamsAdd("pOccupation", "Milkman");
  this.sendEvent("evThingHappened"); // Sends event with the 3 parameters defined above.
}

 

setPropCli()

setPropCli(pPropNumber, pPropValue)

Sets the Omnis property of the control to the value passed.

This is a wrapper for the doSetProperty() method which will also attempt String Table translation on pPropValue, if it is a string.

If you have overridden setProperty() in your control, this will also be called into at the appropriate time.

Parameters:

Returns:

Example

var success = this.setPropCli(eBaseProperties.left, 100);
success = this.setPropCli(eBaseProperties.text, "Hello"); // Will attempt to translate "Hello" using string table.

 

setProperty()

setProperty(pPropNumber, pPropValue)

Sets the given Omnis property to the given value, and performs any other necessary action required by changing this value.

This method will typically be overridden in your JavaScript control, to handle any custom properties, but fall back to the base class' implementation for base properties.

Parameters:

Returns:

Example

var success = this.setProperty(eBaseProperties.fontSize, 12); // Set the font size (handled automatically)
// Set a custom property (must be handled by overridden setProperty() method in your control):
success = this.setProperty(PROPERTIES.iconSize, "100px");

 

setPropertyBorder()

setPropertyBorder(pElem, pValue, pDefault)

Applies the given border style to an element.

Parameters:

Returns:

Example

this.setPropertyBorder(elem, eBaseBorder.Plain);

 

setupIcon()

setupIcon(pUrl)

Gets an icon url from the format sent by Omnis, into a useable and appropriate URL.

Replaces the icon library placeholder ("%L") in the supplied icon URL.

If more than one icon is available, chooses the best icon to use based on the client resolution.

Parameters:

Returns:

Example

// data-icon is: "icons/lib/%l/033333n16.png;033333n16_15x.png;033333n16_2x.png"
var iconAttrib = client_elem.getAttribute("data-icon");
var iconUrl = this.setupIcon(iconAttrib);
// On a retina device, iconUrl will become "icons/lib/myLibrary/033333n16_2x.png"

 

update()

update(pWhat, pRow, pCol)

Call this method to cause your control to be updated.

The update may not be called immediately, but will be flagged to do so at the next available opportunity.

This will end by calling into your control's updateCtrl() method, if necessary.

The parameters only really apply if your control uses a list to define its structure, and you want to optimize your handling of updates. If it does not, you can safely pass no parameters.

Parameters:

Returns:

Example

this.update("COL", 3, 2); // Call update, specifying that just the data in col 2 of the 3rd row has changed.

 

visibilityChanged()

visibilityChanged()

Call this if you wish to check whether your control's visibility has changed (e.g. perhaps it's on a paged pane which is no longer visible).

This checks the visibility of your client element against the value of getTrueVisibility().

This will also set your client element's visibility style to the new value.

Parameters:

Returns:

Example

if (this.visibilityChanged()) {
  this.rebuildMyControl();
}

 

isActive()

isActive()

Returns whether the control is active (based on its state, and the state of any container(s)).

Parameters:

Returns:

Example

var active = this.isActive();

   

getTheme()

getTheme()

Returns the theme object associated with the Omnis instance. Once you have the Theme instance, there are a variety of methods you can use, documented in the Theme Instance Methods section.

Parameters:

Returns:

Example

const theme = this.getTheme();

resolveDefaultColor()

resolveDefaultColor(color, attribute)

Returns the passed color into a concrete color. If it's kColorDefault, turns it into the appropriate theme color constant. Otherwise, returns the color unchanged. Especially useful for calculating the correct text color when on a theme color background – see getTextColorString().

Parameters:

Returns:

Example

const backColor = this.resolveDefaultColor(backgroundColor, BaseDefaultColorAttributes.BACKGROUND);

   

   

Control - Properties

.elem

Type: HTML Element

The control's outer 'Frame' element.

.form

Type: Form

The control's containing Form instance.

 

.mEventFunction

Type: function

You should set this as the handler for your control's HTML events.

Then, when the event is triggered it will pass through the Omnis JavaScript framework, and will call into your class' handleEvent method, where you should handle the event.

Example

ctrl.init_ctrl_inst = function(form, elem, rowCtrl, rowNumber)
{
...
client_elem.onclick = this.mEventFunction;
client_elem.onblur = this.mEventFunction;
...
};

 

.objName

Type: Character

The name of the control.

(Typically something like js1_button_1059)

 

.objNumber

Type: Integer

This is the Object Number of the control. A unique identifier within the form.

  

allowDefaultDropHandling

Type: Boolean

If true, the browser's default drag & drop drop handling will not be prevented for this control.

Defaults to false.

 

baseClassName

Type: String

Controls can override this to provide a space-separated list of css classes which should always be applied to the Client Element.

Set before calling super init_ctrl_inst in order to automatically apply to Client Element initially.

   

DefaultColors

Type: Object

This object contains theme constant values to be used for default theme colors for when a color property is set to kColorDefault. Use with BaseDefaultColorAttributes (found in Constants of the JavaScriptControl Reference) to access the correct member.

See Theme Instance Methods getColorString() and getTextColorString() for examples of how these are used.

   

mAcceptsReturn

Type: Boolean

If this is set to true, pressing the Enter key while the control has focus will not trigger the form’s okkeyobject (if there is one). This should be set if the control performs an action when Enter is pressed.

 

mAcceptsEscape

Type: Boolean

If this is set to true, pressing the Escape key while the control has focus will not trigger the form’s cancelkeyobject (if there is one). This should be set if the control performs an action when Escape is pressed.

 

Form

beginAnimations()

beginAnimations(pDuration, pCurve)

Begins an animation block for the form.

Individual animations are added using your control's doSetProperty() method.

The animation block is run by calling commitAnimations().

Parameters:

Returns:

Example

var formInst = this.form;
formInst.beginAnimations(1000, 4); // Begin animation block
this.doSetProperty(eBaseProperties.left, 300); // Add property change to animation block.
formInst.commitAnimations(); // Run the animations.

 

callMethod()

callMethod(pMethodName, ...)

Calls a form's instance method.

Can be client or server executed.

Parameters:

Returns:

Example

var ret = formInst.callMethod("$echo", "Hello"); // Calls the method $echo passing "Hello" as its first parameter.

 

 

callMethodEx()

callMethodEx(pMethodName, pFlags, ...)

Calls a form instance method

Can be a server or client method.

Parameters:

Returns:

Example

var ret = formInst.callMethodEx("$echo", eDoMethodFlags.clientOnly | eDoMethodFlags.noOverlay, "Hello");
// Calls the form method $echo, only if it's a client-executed method, and prevents the overlay from displaying.

 

commitAnimations()

commitAnimations()

Commit an animation block for the form.

Note that nothing will occur until control returns to the browser, which then applies the CSS transitions.

Animation blocks are initiated using beginAnimations() and individual animations added using a Control's doSetProperty() method.

Parameters:

Returns:

Example

var formInst = this.form;
formInst.beginAnimations(1000, 4); // Begin animation block
this.doSetProperty(eBaseProperties.left, 300); // Add property change to animation block.
formInst.commitAnimations(); // Run the animations.

 

findChild()

findChild(pObjNumber, pRowNumber)

Gets a control on the form by its Object Number.

Parameters:

Returns:

Example

var ctrl = formInst.findChild(3,0) ;

 

findChildByName()

findChildByName(pObjName)

Gets a Control instance by its Object Name.

Parameters:

Returns:

Example

var ctrl = formInst.findChildByName("jsform_button_1056");

 

getData()

getData(pDataIndex, pWhat, pRow, pCol, pFmt, pFormatString)

Returns the data from one of the form's instance variables.

Parameters:

Returns:

Example

// Get the value of the second col from iRow, in a custom date format:
var bday = formInst.getData(formInst.getDataIndex("iRow",
"#COL", 1, 2, "s", "D/M/y");

 

getDataIndex()

getDataIndex(pDataName, pCtrl, pMapControlToData)

Returns the index to an instance data variable.

Also allows you to map the data variable to the control.

Parameters:

Returns:

Example

var dataIndex = formInst.getDataIndex("iList", null, false);

 

getNextPrevTabObject()

getNextPrevTabObject(pStartObj, pIsPrev, pNoWrap)

Gets the next or previous active Control in the tab order.

Parameters:

Returns:

Example

var nextCtrl = formInst.getNextPrevTabObject(this, false);

 

registerForFormBuilt()

registerForFormBuilt(pCtrl)

Call this from your control's init_ctrl_inst() method, if you wish to be notified when the form has finished building.

Your control's formBuilt() method will be called when the form has finished constructing everything.

Parameters:

Returns:

Example

var formInst = jOmnis.getOmnisForm(0,0);
formInst.registerForFormBuilt(this);

 

requestScriptAvailNotify()

requestScriptAvailNotify(pCtrl)

Register the control to be notified when the form script (the generated script containing all the client-executed methods on the form and its controls) is available.

The registered control's scriptAvail() method will be called when the script has loaded.

Parameters:

Returns:

Example

ctrl.init_ctrl_inst = function() {
    ...
    this.form.requestScriptAvailNotify(this);
    ...
};

setData()

setData(pDataIndex, pNewData, pWhat, pRow, pCol, pCanRecord, pFmt, pFormatString)

Assigns data to a form instance variable.

If the instance variable is mapped to a control, that control's updateCtrl() method will also be called, after setting the data, with the values of pWhat, pRow & pCol set here.

Parameters:

Returns:

Example

// Set a list's current line to 5:
formInst.setData(dataIndex, 5, "#L");
// Set the value of the 4th column in the 3rd row to be "Bert":
formInst.setData(dataIndex, "Bert", "#COL", 3, 4);

  

   

jIcons

This is a global object which has replaced some of the methods within jOmnis and added further functionality to work with icons.

getCheckedImage()

getCheckedImage(normalUrl)

Gets the checked image URL corresponding to a normal image URL. According to icon set naming rules. (Previously a jOmnis method)

Parameters:

Returns:

Example

var checkedIcon = jIcons.getCheckedImage("icons/myset/myCheckBox_90001_32x32_2x.png");
//checkedIcon becomes "icons/myset/myCheckBox_90001_32x32c_2x.png"

 

getIconBackSize()

getIconBackSize(iconUrl)

Returns the dimensions of the image, as a string suitable to be applied to an element’s background-size style value. I.e. “<width>px <height>px”

Parameters:

Returns:

Example

myImg.style.backgroundSize = jIcons.getIconBackSize("icons/myset/myIcon_90000_32x32.png");

 

getIconSize()

getIconSize(iconUrl, cssStyle, isSvg)

Returns either an object with width and height members indicating the size of the icon for the url, or a CSS style to set the background size.

If pCssStyle is false, and the size is not available (such as for a stand-alone page not in an ICON set) returns an empty object.

The icon name must conform to Omnis Icon Set naming syntax.

Parameters:

Returns:

If pCssStyle=true, returns a CSS style string. e.g. “background-size: 50px 80px;”
If pCssStyle=false, returns a JavaScript Object containing width and height properties.

Example

const iconWidth = jIcons.getIconSize("icons/myset/myIcon_90000_32x32.png", false).width;

 

replaceOrAddToElem()

replaceOrAddToElem(parentElem, iconUrl, loadFunc, sizeObj, alwaysCreate, needWrapper)

Replaces if present, or adds if absent, an icon to an element.

Parameters:

Returns:

Example

const myElement = document.getElementById("myElement"); // The element to append the icon to.
const sizeObj = {width: 16, height: 16, viewBox: "0 0 24 24"}; // The size object to give a width and height of 16px but use 24px of the SVG viewbox
jIcons.replaceOrAddToElem(myElement, "icons/myicon.svg?", ()=>{window.alert("Icon loaded");}, sizeObj, false); // Adds the icon, myicon.svg, to myElement using the size properties in sizeObj. Displays a message when the image has loaded.

  

 

iconUrl()

iconUrl(imageElem)

Returns the icon URL for the supplied element.

Parameters:

Returns:

Example:

const iconElem = this.clientElem.querySelector("img,svg");
const iconUrl = jIcons.iconUrl(iconUrl); 

 

setImageUrl()

setImageUrl(imageElem, imageUrl)

Replaces the image URL in the supplied image element (svg or img). This is used to switch between checked and normal images, so the type of the image supplied is the same as the current image (img, svg or themed svg).

Parameters:

Returns:

Example:

const iconElem = this.clientElem.querySelector("img,svg");
const checkedImage =
jIcons.getCheckedImage("icons/myset/myCheckBox_90001_32x32_2x.png");
jIcons.setImageUrl(iconElem, checkedImage); 

 

 

jOmnis

addClass()

addClass(pElem, pClassName, addSuffix)

Adds the passed CSS class name(s) to the specified element, if it doesn't already have it.

Parameters:

Returns:

Example

jOmnis.addClass(elem, "myClass myOtherClass");

 

removeClass()

removeClass(pElem, pClassName, withSuffix)

Removes the passed CSS class name(s) from the element.

Parameters:

Returns:

Example

jOmnis.removeClass(elem, "myClass myOtherClass");

 

hasClass()

hasClass(pElem, pClassName)

Checks whether the passed element has the specified CSS class (amongst all of its CSS classes).

Parameters:

Returns:

Example

var hasMyClass = jOmnis.hasClass(client_elem, "myclass");

 

addStyleSheet()

addStyleSheet(pCssText)

Adds a CSS style sheet to the page.

Parameters:

Returns:

Example

var myStyleSheet = jOmnis.addStyleSheet(".myClass{ color: #FF0000;}");

 

removeStyleSheet()

removeStyleSheet(pStyleSheet)

Removes a CSS style sheet from the page.

Parameters:

Returns:

Example

var myStyleSheet = jOmnis.addStyleSheet(".myClass{ color: #FF0000;}");
jOmnis.removeStyleSheet(myStyleSheet);

 

registerStyleSheetObject()

registerStyleSheetObject(pObject)

Registers the passed object (generally a control) to be notified when stylesheets are updated dynamically (using addStyleSheet etc).

The object must implement a method called "styleSheetsUpdated", which will be called when the stylesheets have updated.

Parameters:

Returns:

Example

ctrl.init_ctrl_inst = function() {
    ...
    jOmnis.registerStyleSheetObject(this);
    ...
}

ctrl.styleSheetsUpdated = function() {
    // React to stylesheets being loaded.
}

 

unregisterStyleSheetObject

unregisterStyleSheetObject(pObject)

Unregisters an object (generally a control) from receiving notifications when stylesheets are updated dynamically.

Parameters:

Returns:

Example

jOmnis.unregisterStyleSheetObject(this);

 

loadResource()

loadResource(pURL)

Loads a resource (.js or .css file) dynamically.

Returns a Promise, which will be fulfilled when the resource loads.

(Handles multiple calls to load the same resource)

If you are loading multiple resources, you are advised to instead use loadResources()

Parameters:

Returns:

Example

function onSuccess() {
  // Handle successful load of resource
}
function onFail() {
  // Handle failure to load resource
}
jOmnis.loadResource("scripts/newscript.js").then(onSuccess).catch(onFail);

 

loadResources()

loadResources(pURLs, pOnSuccess, pOnFail)

Asynchronously loads multiple resources (css/js files) in order. Then calls the provided callback function once complete.

Parameters:

Returns:

Example

jOmnis.loadResources([ "css/mycss.css", "scripts/myscript.js"], resourcesReady, resourcesLoadFailure);

 

addSwipeListener()

addSwipeListener(pElem, pStartTouchOK, pMoveHandler, pEndListener, pAnimationDuration)

Adds a swipe listener to handle touch events swiping horizontally across a control.

Parameters:

Returns:

Example

var ctrl = this;
var startTouchFunc = function() { return true; };
var moveHandlerFunc = function(dx, duration) {ctrl.scrollToOffset(startOffset + dx, duration, false);};
var endListenerFunc = function(obj) {alert("Swipe complete");};
jOmnis.addSwipeListener(elem, startTouchfunc, moveHandlerFunc, endListenerFunc, 500);

 

animate()

animate(pElem, pProperties, pTime, pTransitionEndedHandler)

Animates multiple CSS properties of an element, over the given time. Uses CSS transitions to animate.

Parameters:

Returns:

Example

var props = {left: "10px"; width: "100px"};
jOmnis.animate(elem, props, 1000, function() {
  alert("Animation complete!");
});

 

clearAnimations()

clearAnimations(pElem, pTransitionEndedHandler)

Removes any animations from the passed element.

Parameters:

Returns:

Example

jOmnis.clearAnimations(elem, this.myAnimationEndedListener);

 

applyAlphaValueToColorPair()

applyAlphaValueToColorPair(pColorPair, pAlphaValue)

DEPRECATED in 10.2

Color Pairs are no longer needed (all browsers now support alpha), and they do not support Themed Colors. The functions in Theme Instance Methods should be used instead.

Applies a new alpha value to a Color Pair.

Parameters:

Returns:

Example

var colorPair = jOmnis.applyAlphaValueToColorPair("rgb(255,0,0);rgba(255,0,0,0.6)", 0.5);

 

applyColorValueToColorPair()

applyColorValueToColorPair(pColorPair, pColorValue)

DEPRECATED in 10.2

Color Pairs are no longer needed (all browsers now support alpha), and they do not support Themed Colors. The functions in Theme Instance Methods should be used instead.

Applies a new color value to both components of a Color Pair.

Parameters:

Returns:

Example

var colorPair = jOmnis.applyColorValueToColorPair("rgb(255,0,0);rgba(255,0,0,0.6)", 65280); //Make the red color pair green.

 

disableTextSelection()

disableTextSelection(pElem, pReEnable, pReEnableValue)

Disables/re-enables the ability to select text in an element.

Parameters:

Returns:

Example

var oldSelection = jOmnis.disableTextSelection(elem, false); //Disable all selection.
jOmnis.disableTextSelection(elem, true, "text"); //Re-enable text selection.

 

extractColor()

extractColor(pColorPair)

DEPRECATED in 10.2

Color Pairs are no longer needed (all browsers now support alpha), and they do not support Themed Colors. The theme's getColorString() and getTextColorString() should be used instead.

Extracts the color to use from a Color Pair, according to whether the browser supports RGBA

Parameters:

If you want the color to be completely transparent, pass “0.00” for the alpha component. If the function finds this, it maps to “transparent”, for better cross-browser support.

Returns:

Example

var colorString = jOmnis.extractColor("rgb(255,0,0);rgba(255,0,0,0.6)");

 

extractSolidColor()

extractSolidColor(pColorPair)

DEPRECATED in 10.2

Color Pairs are no longer needed (all browsers now support alpha), and they do not support Themed Colors. The theme's getColorString() and getTextColorString() should be used instead.

Extracts the solid color from a Color Pair, as a numeric color string prefixed with #.

Parameters:

Returns:

Example

var colorString = jOmnis.extractSolidColor("rgb(255,0,0);rgba(255,0,0,0.6)");

 

getAttributeAsBool()

getAttributeAsBool(pElem, pAttributeName, pDefaultValue)

Gets an element’s attribute value as a Boolean.

Parameters:

Returns:

Example

var myBool = jOmnis.getAttributeAsBool(elem, "data-custom", false);

 

getAttributeList()

getAttributeList(pElem, pAttributeName, pPrimarySeperator)

Initializes a simple array variable from a comma-separated list in an attribute. The comma-separated list may include a primary separator for a “two-dimensional” array.

Parameters:

Returns:

Example

var myArray = jOmnis.getAttributeList(elem, "data-mylist", "~");
/* Where data-mylist = "0,12,13~2,14,5~9,100,23"
This returns a "2D" array - the first element of the array is itself an array containing 3 values -
0, 12 & 13. The second element is an array containing 2, 14 & 5, and so on...*/

 

getCheckedImage()

getCheckedImage(pNormalUrl)

REMOVED in 10.2

Icon related methods have been moved to jIcons. See getCheckedImage().

Gets the checked image URL corresponding to a normal image URL. According to icon set naming rules.

Parameters:

Returns:

Example

const checkedIcon = jIcons.getCheckedImage("icons/myset/myCheckBox_90001_32x32_2x.png");
//checkedIcon becomes "icons/myset/myCheckBox_90001_32x32c_2x.png"

 

getClientLocale()

getClientLocale()

Gets the client's locale information.

Parameters:

Returns:

Example

var locString = jOmnis.getClientLocale();

cToChar()

cToChar(pValue)

Converts a value to a string, obeying Omnis' rules (e.g. using locale's dp character).

This is the best way to turn an omnis_date type into a string.

Parameters:

Returns:

Example

var omDate = new omnis_date(new Date());
var dateString = jOmnis.cToChar(omDate);

 

rgbFromCssColor()

rgbFromCssColor(pCssColor)

Gets the Omnis rgb color value of a CSS color string.

Parameters:

Returns:

Example

var rgb = this.rgbFromCssColor("#0000FF"); //rgb becomes 16711680

 

getColorString()

getColorString(pRGB)

DEPRECATED in 10.2

Themes require the use of various constants and the functions in Theme Instance Methods have been developed to handle these. The theme's instance methods getColorString() and getTextColorString() should be used instead.

Gets a color value, suitable for use with styles.

Parameters:

Returns:

Example

var blueString = jOmnis.getColorString(16711680);

 

getColorStringWithAlpha()

getColorStringWithAlpha(pRGB, pAlpha)

DEPRECATED in 10.2

Themes require the use of various constants and the functions in Theme Instance Methods have been developed to handle these. The theme's instance methods getColorString() and getTextColorString() should be used instead.

Gets a color value, suitable for use with styles, including alpha when the browser supports it.

Parameters:

Returns:

Example

var blueStringAlpha = jOmnis.getColorStringWithAlpha(16711680,100);

 

getColorStringForElement()

getColorStringForElement(parentElem, className, attrib, colorPair)

Adds a temporary hidden element with the passed className as a child of parentElem. Uses this to create a color or colorPair string from the computed CSS rules which would be applied to the element. The hidden element is removed again once the color has been calculated.

Parameters:

Returns:

Example

var backgroundColor = jOmnis.getColorStringForElement(this.clientElem, "myclass", "backgroundColor", true);

 

getEventCurrentTarget()

getEventCurrentTarget(pEvent)

A browser-agnostic function to return the current target of an event object. This may not be the original target when events are sent to multiple elements.

Parameters:

Returns:

Example

var evCurrTarget= jOmnis.getEventCurrentTarget(event);

 

getEventTarget()

getEventTarget(pEvent)

A browser-agnostic function to return the target of an event object. This may not be the current target when events are sent to multiple elements.

Parameters:

Returns:

Example

var evTarget = jOmnis.getEventTarget(event);

 

getIconBackSize()

getIconBackSize(pUrl)

REMOVED in 10.2

Icon related methods have been moved to jIcons. See getIconBackSize().

Returns the dimensions of the image, as a string suitable to be applied to an element’s background-size style value. I.e. “<width>px <height>px”

Parameters:

Returns:

Example

myImg.style.backgroundSize = jOmnis.getIconBackSize("icons/myset/myIcon_90000_32x32.png");

 

getIconSize()

getIconSize(pUrl, pCssStyle)

REMOVED in 10.2

Icon related methods have been moved to jIcons. See getIconSize().

Returns either an object with width and height members indicating the size of the icon for the url, or a CSS style to set the background size.

If pCssStyle is false, and the size is not available (such as for a stand-alone page not in an ICON set) returns an empty object.

The icon name must conform to Omnis Icon Set naming syntax.

Parameters:

Returns:

If pCssStyle=true, returns a CSS style string. e.g. “background-size: 50px 80px;”
If pCssStyle=false, returns a JavaScript Object containing width and height properties.

Example

var iconWidth = jOmnis.getIconsize("icons/myset/myIcon_90000_32x32.png", false).width;

 

getOmnisForm()

getOmnisForm(pInstIndex, pFormIndex)

Gets a reference to an Omnis Form.

Parameters:

Returns:

Example

var omForm1 = jOmnis.getOmnisForm(0,0);

 

getOmnisFormControl()

getOmnisFormControl(pInstIndex, pFormIndex, pObjNumber, pObjRowNumber)

Gets a reference to an individual Control on a form.

Parameters:

Returns:

Example

var omnisCtl1 = jOmnis.getOmnisFormControl(0,0,1,0);

 

getOmnisHeight()

getOmnisHeight(pElem, pClientArea)

Gets the height of the element, according to Omnis rules, for the frame or client areas.

Parameters:

Returns:

Example

var height= jOmnis.getOmnisHeight(elem, false);

 

getOmnisInst()

getOmnisInst(pInstIndex)

Gets a reference to an Omnis Instance.

Parameters:

Returns:

Example

var omInst1 = jOmnis.getOmnisInst(0);

 

getOmnisLeft()

getOmnisLeft(pElem)

Gets the left position of the element, according to Omnis rules. This is the left position within the parent element, left of CSS border.

Parameters:

Returns:

Example

var leftPos = jOmnis.getOmnisLeft(elem);

 

getOmnisTop()

getOmnisTop(pElem)

Gets the top position of the element, according to Omnis rules. This is the top position within the parent element, top of CSS border.

Parameters:

Returns:

Example

var topPos = jOmnis.getOmnisTop(elem);

 

getOmnisWidth()

getOmnisWidth(pElem, pClientArea)

Gets the width of the element, according to Omnis rules, for the frame or client areas.

Parameters:

Returns:

Example

var width = jOmnis.getOmnisWidth(elem, false);

 

getStyle()

getStyle(pElem, pStyleName, pDoParseInt)

Returns the current specified style attribute. This works regardless of how the style was specified, i.e. via style sheets or the style attribute.

Parameters:

Returns:

Example

var leftPad = jOmnis.getStyle(elem, "padding-left", true);

 

getTotalHeight()

getTotalHeight(pElem)

Gets the total CSS height of the element.

Parameters:

Returns:

Example

var totalHeight = jOmnis.getTotalHeight(elem);

 

getTotalWidth()

getTotalWidth(pElem)

Gets the total CSS width of the element.

Parameters:

Returns:

Example

var totalWidth = jOmnis.getTotalWidth(elem);

 

getWindowClientScroll()

getWindowClientScroll()

Gets the X and Y scroll offsets of the window client area in a JavaScript object .

Parameters:

Returns:

Example

var topPos = jOmnis.getWindowClientScroll().YOffset;

 

getWindowClientSize()

getWindowClientSize()

Gets the width and height of the window client area in a JavaScript object.

Parameters:

Returns:

Example

var clientWidth = jOmnis.getWindowClientSize().width;

 

inAppWrapper()

inAppWrapper()

Returns whether the client is running in a wrapper app.

Parameters:

Returns:

Example

this.inWrapper = jOmnis.inAppWrapper();

 

okMessage()

okMessage(pTitle, pMessage)

Opens an OK message dialog. Same as $showmessage() from Omnis code.

Parameters:

Returns:

Example

jOmnis.okMessage("My Title", "My Message");

 

showDialogEx()

showDialogEx(pTitle, pMessage, pType, pWidth, pHeight, pAutohide, pAtCursor, pModal, pHasClose, pButtonList, pFormInst)

Opens a dialog, with several customizable options.

Parameters:

Returns:

Example

var buttonList = new Array( new button(jOmnis.yesString, true, $yesEvent, jOmnis.yesAccel),
          new button(jOmnis.noString, false, "$noEvent", jOmnis.noAccel),
          new button(jOmnis.cancelString, false, "$cancelEvent", null) );
jOmnis.showDialogEx("myTitle", "My Message", "message", 0, 0, null, false, true, false, buttonList, formInst);

 

parseInteger()

parseInteger(pString)

Converts a string to an integer.

Parameters:

Returns:

Example

var myInt = jOmnis.parseInteger("123");

 

setBackgroundFromOmnisDefinition()

setBackgroundFromOmnisDefinition(pElem, pAttName, pDestElem)

Sets the element’s background color and alpha from the element’s “data-backgroundcolor” attribute (which specifies a Color Pair).

Parameters:

Returns:

Example

jOmnis.setBackgroundFromOmnisDefinition(elem);

 

setBorderRadius()

setBorderRadius(pElem, pValue)

Sets the border radius of the specified element.

Parameters:

Returns:

Example

jOmnis.setBorderRadius(elem, "10-5");

 

setOmnisHeight()

setOmnisHeight(pElem, pNewHeight)

Sets the height of the element, according to Omnis rules. The height includes the borders and everything inside.

Parameters:

Returns:

Example

jOmnis.setOmnisHeight(elem, 150);

 

setOmnisLeft()

setOmnisLeft(pElem, pNewLeft)

Sets the left position of the element, according to Omnis rules. This is the left position within the parent element, left of CSS border.

Parameters:

Returns:

Example

jOmnis.setOmnisLeft(elem, 120);

 

setOmnisRect()

setOmnisRect(pElem, pNewLeft, pNewTop, pNewWidth, pNewHeight)

Sets the position and dimensions of the given element, according to Omnis rules.

Parameters:

Returns:

Example

jOmnis.setOmnisRect(elem, 120, 10, 200, 150);

 

setOmnisTop()

setOmnisTop(pElem, pNewTop)

Sets the top position of the element, according to Omnis rules. This is the top position within the parent element, top of CSS border.

Parameters:

Returns:

Example

jOmnis.setOmnisTop(elem, 10);

 

setOmnisWidth()

setOmnisWidth(pElem, pNewWidth)

Sets the width of the element, according to Omnis rules. The width includes the borders and everything inside.

Parameters:

Returns:

Example

jOmnis.setOmnisWidth(elem, 200);

 

setPropertyBackground()

setPropertyBackground(pElem, pPropNumber, pValue)

Sets the element’s background color or alpha.

Parameters:

Returns:

Example

var success = jOmnis.setPropertyBackground(elem, eBaseProperties.backcolor, 65280);
success = jOmnis.setPropertyBackground(elem, eBaseProperties.backalpha, 0.5);

 

stopEventNow()

stopEventNow(pEvent)

Immediately stops the browser from processing the event any further. (i.e. prevents event bubbling, etc.)

Parameters:

Returns:

Example

jOmnis.stopEventNow(event);

 

setFontSize()

setFontSize(pElem, pSize)

Sets the point size of a font for an element. Allows for special processing for point size zero. (Zero defaults to point size 9)

Parameters:

Returns:

Example

jOmnis.setFontSize(elem, 12);

 

getElemPosRelativeToAncestor()

getElemPosRelativeToAncestor(pElem, pAncestor)

Gets the top and left CSS coordinates of an element relative to its ancestor.

Parameters:

Returns:

Example

var relPos = jOmnis.getElemPosRelativeToAncestor(elem, ancestor);

 

 

getDefaultDateFormatCustom()

getDefaultDateFormatCustom()

Gets the default value for the custom format string.

Parameters:

Returns:

Example

var defDateFmt = jOmnis.getDefaultDateFormatCustom();

 

setDefaultDateFormatCustom()

setDefaultDateFormatCustom(pFormat)

Sets the default value for the custom format string.

Parameters:

Returns:

Example

var fmt = "D/M/y"
jOmnis.setDefaultDateFormatCustom(fmt);

 

getLocaleTimeFormat()

getLocaleTimeFormat()

Gets the client’s localized time format string.

Parameters:

Returns:

 

getLocaleShortDateFormat()

getLocaleShortDateFormat()

Gets the client’s localized short date format string.

Parameters:

Returns:

  

getLocaleShortDateTimeFormat()

getLocaleShortDateTimeFormat()

Gets the client’s localized short datetime format string.

Parameters:

Returns:

  

getLocaleMediumDateFormat()

getLocaleMediumDateFormat()

Gets the client’s localized medium date format string.

Parameters:

Returns:

 

getLocaleMediumDateTimeFormat()

getLocaleMediumDateTimeFormat()

Gets the client’s localized medium datetime format string.

Parameters:

Returns:

 

getLocaleLongDateFormat()

getLocaleLongDateFormat()

Gets the client’s localized long date format string.

Parameters:

Returns:

 

getLocaleLongDateTimeFormat()

getLocaleLongDateTimeFormat()

Gets the client’s localized long datetime format string.

Parameters:

Returns:

 

getLocaleFullDateFormat()

getLocaleFullDateFormat()

Gets the client’s localized full date format string.

Parameters:

Returns:

 

getLocaleFullDateTimeFormat()

getLocaleFullDateTimeFormat()

Gets the client’s localized full datetime format string.

Parameters:

Returns:

 

trim()

trim(pString, pChars)

Trims any leading or trailing characters which match those defined in pChars, from the string.

Use ltrim() to trim only leading characters.

Use rtrim() to trim only trailing characters.

Parameters:

Returns:

Example

var str = jOmnis.trim("aaaaaaaHelloaaa","a"); //Returns "Hello"

 

ltrim()

ltrim(pString, pChars)

Same as trim(), but only trims leading chars. See trim() for details.

 

rtrim()

rtrim(pString, pChars)

Same as trim(), but only trims trailing chars. See trim() for details.

 

inFirefox()

inFirefox()

Returns whether the client is running in Firefox.

Parameters:

Returns:

 

inOpera()

inOpera()

Returns whether the client is running in Opera.

Parameters:

Returns:

 

inChrome()

inChrome()

Returns whether the client is running in Chrome.

Parameters:

Returns:

 

inSafari()

inSafari()

Returns whether the client is running in Safari.

Parameters:

Returns:

 

inEdge()

inEdge()

Returns whether the client is running in Edge.

Parameters:

Returns:

 

 

getMethod()

getMethod(pObj, pOmnisMethodName, pInhLevel)

Gets the name of a method in the object, from the Omnis method name.

Parameters:

Returns:

Example

var methodName = jOmnis.getMethod(this, "$myMethod", -1);
this[methodName].call(this, "p1",123); // First argument to call() is what the method will use as "this".

 

doMethod()

doMethod(pCallType, pObj, pOmnisMethodName, pFlags, ...)

Calls a method relative to object pObj ("Do method" command implementation).

For calling a method of your control, see callMethod()

Parameters:

Returns:

Example

// Call an instance method of your form:
var rtn = jOmnis.doMethod(eAnums.$cinst, this, "$myMethod", eDoMethodFlags.completionEvent,"param1",123);

 

defaultParameter()

defaultParameter(pParam, pDefaultValue)

A helper method to help ensure parameters are initialized with valid values. E.g. Especially useful for optional parameters.

Checks if pParam has been passed (i.e. not null) - if so, it is returned.

If the parameter is null, pDefaultValue is returned.

Parameters:

Returns:

Example

ctrl_generic.prototype.myMethod = function(p1) {
  p1 = jOmnis.defaultParameter(p1, 0); // Ensure p1 is not null.
  var myVal = p1 * 100; // would cause an error if p1 was null.
};

 

clientPlatform

Type: Integer

An eClientPlatforms value specifying the platform the client is running on.

 

inFirefoxiOS()

inFirefoxiOS()

Returns true if running in Firefox on iOS.

Parameters:

Returns:

Example

if (jOmnis.inFirefoxiOS()) {
  // Some workaround
}

 

inChromeiOS()

inChromeiOS()

Returns true if running in Chrome on iOS.

Parameters:

Returns:

Example

if (jOmnis.inChromeiOS()) {
  // Some workaround.
}

 

deepCopy()

deepCopy(pObj)

Returns a deep copy of the passed object.

Parameters:

Returns:

Example

var clone = jOmnis.deepCopy(myObj);

 

getURLParameters()

getURLParameters()

Returns a JSON object containing the current URL's query parameters' keys & values.

All values will be treated as strings.

Parameters:

Returns:

Example

// User opened the form by visiting http://mysite.com/omnisform?Name=Bert&Age=12
var urlParams = jOmnis.getURLParameters();
// urlParams = {Name: "Bert", Age: "12"}

 

sendDOMEvent()

sendDOMEvent(pTargetElem, pEventType, pBubbles)

Sends an event of the specified type to the passed element.

Parameters:

Returns:

Example

jOmnis.sendDOMEvent(theElem, "click", true);

 

getContainerControl()

getContainerControl(pElem)

Gets the specified element's container control. If none exists, return null.

Parameters:

Returns:

Example

var container = jOmnis.getContainerControl(client_elem);

  

  

   

jStyles

This is a global object which allows for more efficient style queries on the same element.

If you are using jOmnis.getStyle() multiple times on the same element, you can improve efficiency by using jStyles.

setElem()

setElem(pElem)

Sets up the object for the element whose styles you wish to query.

You must make this call before using get() or getInt().

Parameters:

Returns:

Example

jStyles.setElem(elem); //sets up the object to get styles for elem.
var style1 = jStyles.get(styleName); // Get the value for styleName style.
var style2 = jStyles.getInt(styleName); // Get the value for styleName style parsed as an integer.
jStyles.done(); // Make sure to call to perform necessary clean up.

 

get()

get(pStyleName)

Gets the value of the passed style name from the element defined in setElem().

Once you have queried the element for all of the styles you require, you must make sure to call jStyles.done().

Parameters:

Returns:

Example

jStyles.setElem(elem); //sets up the object to get styles for elem.
var style1 = jStyles.get(styleName); // Get the value for styleName style.
var style2 = jStyles.getInt(styleName); // Get the value for styleName style parsed as an integer.
jStyles.done(); // Make sure to call to perform necessary clean up.

 

getInt()

getInt(pStyleName)

Gets the Integer value of the passed style name from the element defined in setElem().

Once you have queried the element for all of the styles you require, you must make sure to call jStyles.done().

Parameters:

Returns:

Example

jStyles.setElem(elem); //sets up the object to get styles for elem.
var style1 = jStyles.get(styleName); // Get the value for styleName style.
var style2 = jStyles.getInt(styleName); // Get the value for styleName style parsed as an integer.
jStyles.done(); // Make sure to call to perform necessary clean up.

 

done()

done()

You must call done() on jStyles after you have finished querying the element for styles. This will perform clean up logic, and remove any cloned elements created during this process from the DOM.

It is not necessary to call done() if you are about to call setElem() again on a different element.

Parameters:

Returns:

Example

jStyles.setElem(elem); //sets up the object to get styles for elem.
var style1 = jStyles.get(styleName); // Get the value for styleName style.
var style2 = jStyles.getInt(styleName); // Get the value for styleName style parsed as an integer.
jStyles.done(); // Make sure to call to perform necessary clean up.

    

  

Theme - Static Properties

The Theme has some static properties that are accessed without requiring the need to get the instance first.

These are accessed via window.Theme (or simply Theme).

 

.COLORS

Type: Object

The key-value pairs of theme constants, which match with their respective kJSThemeColor… constant in Omnis.

 Example

console.log(Theme.COLORS.primary); // logs to the console: -2147483462 (the same value as kJSThemeColorPrimary)

 

.COLOR_NAMES

Type: Object

The key-value pairs of theme constant names.

    

  

   

Theme - Instance Methods

The Theme instance can be obtained from any control by calling getTheme() as documented in the Control – Instance Methods section.

The Theme contains methods to get the correct theme colors to apply to elements. These methods replace a lot of the color functionality, which have been deprecated, from jOmnis.

In Studio 11, static versions of the theme instance methods getColorString() and getTextColorString() were added. The static versions are the same as the instance methods except you don't need a theme instance to call them.

The existing instance methods are retained for backwards compatibility, but they are deprecated in Studio 11 and you should use the new static versions.

getColorString()

getColorString(color, defaultColor, alpha)

Gets string suitable for assigning to a css style.

Parameters:

Returns:

Example

const theme = this.getTheme(); // Called from within a control to get the theme object.
const colorStr = theme.getColorString(newColor, this.DefaultColors[BaseDefaultColorAttributes.BACKGROUND], 1); // Get the color string for newColor value, defaults to this.DefaultColors[BaseDefaultColorAttributes.BACKGROUND] and applies and alpha of 1.
this.client_elem.style.backgroundColor = colorStr; // Assign the background color of the client element to colorStr.

 

getTextColorString()

getTextColorString(textColor, onColor, defaultColor)

Gets string suitable for assigning to a css style similar to getColorString() but automatically calculates the text color based on the onColor if textColor is kColorDefault and onColor is a theme color with an associated text color.

Parameters:

Returns:

Example

const theme = this.getTheme(); // Called from within a control to get the theme object.
backColor = this.resolveDefaultColor(backColor, BaseDefaultColorAttributes.BACKGROUND); // ensure backColor is resolved to a color constant if it is set to kColorDefault.
const textColorStr = theme.getTextColorString(newTextColor, backColor, this.DefaultColors[BaseDefaultColorAttributes.TEXT]); // Get the color string for newTextColor value, which is to be displayed on backColor, defaults to this.DefaultColors.TEXT
this.client_elem.style.color = textColorStr; // Assign the color of the client element to textColorStr.

 

getColorRGB()

getColorRGB(color, defaultColor)

Gets the resolved Omnis RGB Integer of the specified color (resolves color constants to their true RGB values).

Parameters:

Returns:

Example

 

const theme = this.getTheme(); // Called from within a control to get the theme object.
const rgbValue = theme.getColorRGB(this.getProperty(eBaseProperties.backcolor));

OMColor

The OMColor class provides static helper methods for common color operations.

TintRGB()

TintRGB(rgbInt, tintFactor, tintType)

A static function which creates a new Omnis RGB Integer which is tinted to become a lighter or darker shade.

Parameters:

  Returns:

Example

const theme = this.getTheme();
const bgColor = theme.getColorRGB(this.getProperty(eBaseProperties.backcolor));
const tintedColor = OMColor.TintRGB(bgColor);

TintRGBWithColor()

TintRGBWithColor (baseRGB, tintRGB, tintFactor)

A static function which creates a new Omnis RGB Integer which is tinted towards the passed 'tintRGB' color.

Parameters:

  Returns:

Example

const theme = this.getTheme();
const bgColor = theme.getColorRGB(this.getProperty(eBaseProperties.backcolor));
const redTintColor = 0x0000FF;
const tintedColor = OMColor.TintRGBWithColor(bgColor, redTintColor, OMColor.eTintFactor.SMALL); // Returns the background color, tinted slightly towards red.

eTintFactor

A static enum representing some default tint factors, which can be applied to OMColor's tinting functions.

Values

eTintType

A static enum representing whether to lighten or darken the color, when used with OMColor.TintRGB).

Values

jOmnisEffects

This class provides ways of adding visual effects.

It is available globally, on the window.

addRippleToElem()

addRippleToElem(elem, theme, hasContainer, elemColor, keys, keyElement, directColor)

Adds a ripple effect to the passed element.

Only add once - once added, the ripple effect will be triggered whenever the element is clicked (or optional keys are pressed while it has focus).

Parameters:

Returns

Example

const theme = this.getTheme();
jOmnisEffects.addRippleToElem(
this.getClientElem(),
theme,
false,
this.getProperty(eBaseProperties.backcolor),
["Enter", " "], // trigger the ripple effect if Enter or spacebar are pressed
null,
0x0000ff // Set the ripple color directly to red.
);

setRippleColor()

setRippleColor(elem, theme, elemColor, directColor)

Updates the color of a previously created ripple element.

Parameters:

Example

const theme = this.getTheme();
jOmnisEffects.setRippleColor(
this.getClientElem(),
theme,
this.getProperty(eBaseProperties.backcolor), // this could be null as 'directColor' is specified
0x00ff00 // Set the ripple color directly to green.
);