Skip to content

controls.js

This page contains the full API reference for controls.js, which provides dialog boxes for custom pages, and buttons, sliders and progress bars.

For how to use dialogs and sliders on a custom page, with examples, see Custom pages: dialogs, tabs, sliders and diagrams.

Dialogs

The dialog functions return immediately (with the dialog's element), and call your function when the user closes the dialog. The messages can contain HTML.

dlgMessage()

dlgMessage(title, string, modal, error, callback, param) shows a message with a Close button.

Parameter Required Default Description
title ✔ Title of the dialog
string ✔ The message (HTML)
modal false true stops the user using the rest of the page until the dialog is closed
error false true shows the title as an error
callback Function called as callback(param) when the dialog is closed
param Passed to callback

dlgAlert()

dlgAlert(s, callback) shows a modal message with the title "Message". It is the same as dlgMessage('Message', s, true, false, callback).

Parameter Required Default Description
s ✔ The message (HTML)
callback Function called when the dialog is closed

dlgConfirm()

dlgConfirm(string, confirmCallback, param) asks the user to click OK or Cancel.

Parameter Required Default Description
string ✔ The question (HTML)
confirmCallback ✔ Function called as confirmCallback(ok, param), where ok is true for OK and false for Cancel
param Passed to confirmCallback

dlgQuery()

dlgQuery(string, value, queryCallback, param, size) asks the user to type some text.

Parameter Required Default Description
string ✔ The question (HTML)
value ✔ Initial text in the input field
queryCallback ✔ Function called as queryCallback(answer, param), where answer is the text, or false for Cancel
param Passed to queryCallback
size 30 Width of the input field, in characters

dlgWait()

dlgWait(time, string, func, param) shows a "Please wait..." dialog with a progress bar, which closes itself.

Parameter Required Default Description
time ✔ How long to show the dialog, in seconds
string ✔ The message (HTML)
func Function called as func(param) when the dialog closes
param Passed to func

dlgGeneral() and dlgListBox()

dlgGeneral(p) shows a dialog containing your own HTML, and dlgListBox(p) a dialog holding a list. p is an object with these properties:

Property Required Default Description
html ✔ Contents of the dialog
title Title of the dialog
iddiv ID of the dialog's element. An existing element with this ID is removed first
width, height dlgGeneral: 400, 100. dlgListBox: 400, 200 Initial size, in pixels
minWidth, minHeight The initial size Smallest size the user can resize the dialog to
x, y Initial position, in pixels

Buttons, sliders and progress bars

The Controls class sets up elements with these name attributes when the page loads:

Name Description
ctrlButton A button containing a canvas. data-draw names a function called as f(canvas) to draw on it
ctrlHSlider A horizontal slider. Requires a width in its style attribute
ctrlVSlider A vertical slider. Requires a height in its style attribute
ctrlProgress A progress bar

Sliders accept these attributes:

Attribute Required Default Description
data-min-value 0 Value at the left (or bottom) end
data-max-value 1 Value at the right (or top) end
data-scale 1 shows the minimum and maximum values at the ends
data-update Name of a function called as f(value, final) when the user moves the slider. final is false while the slider is being dragged, and true when the user lets go of it (or right-clicks it, which returns it to the middle)

resources/custom_example.html has examples of all these elements.

Functions and variables

Classes

Controls

function Controls()

Defined in resources/controls.js:245

Methods
ctrlHSliderDraw
Controls.prototype.ctrlHSliderDraw = function(b)

Defined in resources/controls.js:465

ctrlHSliderHandler
Controls.prototype.ctrlHSliderHandler = function(e)

Defined in resources/controls.js:539

ctrlHSliderSet
Controls.prototype.ctrlHSliderSet = function(value)

Defined in resources/controls.js:529

ctrlProgressSet
Controls.prototype.ctrlProgressSet = function(value)

Defined in resources/controls.js:586

ctrlVSliderDraw
Controls.prototype.ctrlVSliderDraw = function(b)

Defined in resources/controls.js:353

ctrlVSliderHandler
Controls.prototype.ctrlVSliderHandler = function(e)

Defined in resources/controls.js:418

ctrlVSliderSet
Controls.prototype.ctrlVSliderSet = function(value)

Defined in resources/controls.js:408

init
Controls.prototype.init = function()

Defined in resources/controls.js:249

Functions

checkResize

function checkResize(dlg, e)

Defined in resources/controls.js:675

ctlInit

function ctlInit()

Defined in resources/controls.js:240

dlgAlert

function dlgAlert(s, callback)

Defined in resources/controls.js:1204

dlgCenter

function dlgCenter(dlg)

Defined in resources/controls.js:651

dlgClose

function dlgClose(div)

Defined in resources/controls.js:1116

dlgConfirm

function dlgConfirm(string, confirmCallback, param)

Defined in resources/controls.js:1208

dlgFocusableControls

function dlgFocusableControls(dlg, selector)

Return eligible controls, excluding disabled and hidden dialog content.

Defined in resources/controls.js:736

dlgGeneral

function dlgGeneral(p)

Populate a modal with a general html

Defined in resources/controls.js:1233

dlgHide

function dlgHide(dlg)

Defined in resources/controls.js:1126

dlgListBox

function dlgListBox(p)

Populate a growing, scrollable dialog with general html

Defined in resources/controls.js:1297

dlgLoad

function dlgLoad(url)

Defined in resources/controls.js:597

dlgMessage

function dlgMessage(title, string, modal, error, callback, param)

Defined in resources/controls.js:1177

dlgMessageDestroy

function dlgMessageDestroy(b)

Defined in resources/controls.js:1153

dlgMove

function dlgMove(d, x, y)

Defined in resources/controls.js:1111

dlgQuery

function dlgQuery(string, value, queryCallback, param, size)

Defined in resources/controls.js:1380

dlgQueryKeyDown

function dlgQueryKeyDown(event, inp)

Defined in resources/controls.js:1358

dlgShow

function dlgShow(dlg, modal, param)

Defined in resources/controls.js:751

dlgWait

function dlgWait(time, string, func, param)

Defined in resources/controls.js:1416

drawCloseButton

function drawCloseButton(c, mark)

Defined in resources/controls.js:627

updateDlgWaitProgress

function updateDlgWaitProgress()

Defined in resources/controls.js:1456

Variables

controls_css

let controls_css = …

default styles for dialog boxes

Defined in resources/controls.js:131

dlgLoadedDialogs

var dlgLoadedDialogs = []

Defined in resources/controls.js:595

dlgTabHandlerInstalled

let dlgTabHandlerInstalled = false

Defined in resources/controls.js:749

dlgWaitDialog

let dlgWaitDialog

Defined in resources/controls.js:1410

dlgWaitFunc

let dlgWaitFunc

Defined in resources/controls.js:1413

dlgWaitFuncParam

let dlgWaitFuncParam

Defined in resources/controls.js:1414

dlgWaitProgress

let dlgWaitProgress

Defined in resources/controls.js:1411

dlgWaitTime

let dlgWaitTime

Defined in resources/controls.js:1412