The dialogs module represents the QuarkXPress application's user interface for dialogs in java scripting world. You can use its properties and methods for user interaction.
Methods
(static) alert(descriptionopt, alertTypeopt) → {undefined}
This method displays an alert dialog with the optional specified content and an OK button.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
description |
string |
<optional> |
""
|
It is an optional string of text you want to display in the alert dialog. |
alertType |
app.constants.alertTypes |
<optional> |
app.constants.alertTypes.kNoteAlert
|
type of alert you want to show. |
Returns:
- Type
- undefined
(static) closeDialog(result) → {undefined}
This method closes the top most dialog.
Example
app.dialogs.closeDialog("dialog close");
app.dialogs.closeDialog({isOk:true, data:"selected values" })
app.dialogs.closeDialog({isOk:true, data:{projectName:"qxp", layoutName:"layoutName" } })
Parameters:
Name | Type | Description |
---|---|---|
result |
any | this result will be available as the callback data in dialogCloseCallback registered by openDialog see openDialog. |
Returns:
- Type
- undefined
(static) confirm(descriptionopt, alertTypeopt) → {boolean}
This method displays a dialog box with a specified message, along with OK and Cancel button.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
description |
string |
<optional> |
""
|
It is an optional string of text you want to display in the alert dialog. |
alertType |
app.constants.alertTypes |
<optional> |
app.constants.alertTypes.kNoteAlert
|
type of alert you want to show. |
Returns:
The method returns true if the user clicks "OK", and false otherwise.
- Type
- boolean
(static) openDialog(url, windowNameopt, windowFeaturesopt, dialogCloseCallbackopt) → {undefined}
This method loads the specified resource into the QuarkXPress's model dialog with the specified name.
If the resource doesn't exist, then a new empty model dialog is opened.
Example
app.dialogs.openDialog("http://www.quark.com", "Quark", "height=500,width=1000");
app.dialogs.openDialog("http://www.quark.com", "Quark", "resizable=yes");
app.dialogs.openDialog("http://www.quark.com", "Quark", "height=500,width=1000", (data)=>{console.log('dialog closed')});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
url |
string | This can be a path or URL to an HTML page, currently only absolute path is supported. | ||
windowName |
string |
<optional> |
${app Name}
|
Specifying the name or title of the model dialog. |
windowFeatures |
string |
<optional> |
""
|
A string containing a comma-separated list of window features, These features include options such as the window's default size and position, supported features are height,width and resizable. |
dialogCloseCallback |
dialogCloseCallback |
<optional> |
Called after dialog gets closed either through see closeDialog or clicking cross icon. |
Returns:
- Type
- undefined
(static) openFileDialog(titleopt, defaultFolderopt, acceptTypesopt) → {string|null}
This method displays a dialog to select a file.
Example
let acceptTypes = [{ types: ['doc', 'docx'], typesName: 'Word documents' }, { types: ['jpg', 'png'], typesName: 'Picture Files' }];
var path = app.dialogs.openFileDialog("Select file to import", "c:\\", acceptTypes);
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string |
<optional> |
""
|
The title of the dialog (e.g. Choose Logs Folder). |
defaultFolder |
string |
<optional> |
""
|
The default location to select file from. |
acceptTypes |
string |
<optional> |
""
|
Default accepted types in the format '[{ "types": "jpeg, png", "typesNames" : "All Picture Files" }]' or 'jpeg, png, tiff, pdf'; |
Returns:
The method returns complete filepath of the file selected by user or null incase user cancel the operation.
- Type
- string | null
(static) openFolderDialog(titleopt, defaultFolderopt) → {string|null}
This method displays a dialog to select a folder.
Example
var path = app.dialogs.openFolderDialog("Choose Logs Folder", "c:\\");
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string |
<optional> |
""
|
Default Title of the dialog e.g. 'Choose Logs Folder'. |
defaultFolder |
string |
<optional> |
""
|
The default location of the folder. |
Returns:
The method returns the path of the folder selected by user or null incase user cancel the operation.
- Type
- string | null
(static) openProgressDialog(titleopt) → {undefined}
This method starts showing indeterminate progress indicator dialog.
To close the progress dialog see closeDialog
Example
app.dialogs.openProgressDialog("Executing script.....");
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string |
<optional> |
""
|
The main title of the progress bar dialog. |
Returns:
- Type
- undefined
(static) prompt(descriptionopt, defaultValueopt) → {any}
This method displays a dialog box that prompts the user for input.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
description |
string |
<optional> |
""
|
It is an optional string of text you want to display in the prompt dialog. |
defaultValue |
defaultValue |
<optional> |
""
|
The default input text. |
Returns:
The method returns the input value if the user clicks "OK". If the user clicks "Cancel" the method returns null.
- Type
- any
(static) saveFileDialog(titleopt, defaultFolderopt, acceptTypesopt, fileNameopt) → {string|null}
This method displays a dialog to save a file.
Example
let acceptTypes = [{ types: ['doc', 'docx'], typesName: 'Word documents' }, { types: ['jpg', 'png'], typesName: 'Picture Files' }];
var path = app.dialogs.saveFileDialog("Save File", "c:\\Temp", acceptTypes, "abc.docx");
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string |
<optional> |
""
|
Default Title of the dialog (e.g. 'Save Project'). |
defaultFolder |
string |
<optional> |
""
|
The default location to save file at (i.e. 'C:\\Temp'). |
acceptTypes |
string |
<optional> |
""
|
Default accepted types in the format '[{ "types": "jpeg, png", "typesNames" : "All Picture Files" }]' or 'jpeg, png, tiff, pdf'. |
fileName |
string |
<optional> |
""
|
Default name of the file to save. (e.g. 'abc.qxp'). |
Returns:
The method returns complete filepath of the new file to be saved at or null incase user cancel the operation.
- Type
- string | null
(static) selectItem(titleopt, descriptionsopt, itemsopt, defaultItemopt, windowFeaturesopt, callbackopt) → {itemInfo|app.APIError}
This method displays a dialog to select an item from the avaialble list.
Example
let items = [{id:1, name:'Red'}, {id:2, name:'Green'}, {id:3, name:'Blue'}, {id:4, name:'Megenta'}];
app.dialogs.selectItem("Select Color", "Color:", items, items[2], (result)=>{console.log(result);});
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
title |
string |
<optional> |
""
|
Default Title of the dialog (e.g. 'Color'). |
descriptions |
string |
<optional> |
""
|
lable of items. |
items |
Array.<itemInfo> |
<optional> |
[]
|
array of items |
defaultItem |
itemInfo |
<optional> |
item to select by default | |
windowFeatures |
string |
<optional> |
Optional. A comma-separated list of features like height=200,width=300, no whitespaces. | |
callback |
dialogCloseCallback |
<optional> |
called after dialog gets closed. |
Returns:
Returns the selected itemInfo on success else APIError.
- Type
- itemInfo | app.APIError