Dialog
Defined in: window/dialog.ts:54
This class is used to spawn new browser processes that can be used to open other URLs. Source plugins do not have this functionality (but their properties windows may use this.)
Note that opening a new dialog replaces the old one. Also, dialogs are considered to be the same type of window as their parent windows: e.g., dialogs from extension windows are considered by the framework to have access to the same functions as extensions.
Most of the methods are chainable.
Sample usage:
var xjs = require('xjs');var Dialog = xjs.Dialog;
xjs.ready().then(function() { var button = document.getElementById('openDialogButton'); button.addEventListener('click', function() { xjs.Dialog.createDialog('your.url/here.html') .setSize(500, 800) .setTitle('ThisDialogReturnsAString') .setBorderOptions(true, false) .setButtons(true, true) .setCookiePath('cookiePath') .show(function(dialog) { dialog.getResult().then(function(result) { document.getElementById('input').value = result; }); }) });});
// in the opened dialog, call Dialog.return() to return a value//// see documentation below for more detailsConstructors
Section titled “Constructors”Constructor
Section titled “Constructor”new Dialog():
Dialog
Defined in: window/dialog.ts:68
Returns
Section titled “Returns”Dialog
Methods
Section titled “Methods”close()
Section titled “close()”close():
Promise<any>
Defined in: window/dialog.ts:378
Closes the dialog that this window spawned.
Returns
Section titled “Returns”Promise<any>
getResult()
Section titled “getResult()”getResult():
Promise<string>
Defined in: window/dialog.ts:334
return: Promise
Gets the string result returned from the spawned dialog.
Returns
Section titled “Returns”Promise<string>
setBorderOptions()
Section titled “setBorderOptions()”setBorderOptions(
showBorder?,resizable?):Dialog
Defined in: window/dialog.ts:204
param: (showBorder: boolean, resizable: boolean)
return: Dialog
Specifies the border and resizable flags for the dialog to be displayed.
Chainable.
Parameters
Section titled “Parameters”showBorder?
Section titled “showBorder?”boolean = false
resizable?
Section titled “resizable?”boolean = false
Returns
Section titled “Returns”Dialog
setButtons()
Section titled “setButtons()”setButtons(
isMinimizeActive?,isMaximizeActive?):Dialog
Defined in: window/dialog.ts:223
param: (isMinimizeActive: boolean, isMaximizeActive: boolean)
return: Dialog
Specifies if the window buttons (minimize and maximize) should be active.
Chainable.
Parameters
Section titled “Parameters”isMinimizeActive?
Section titled “isMinimizeActive?”boolean = false
isMaximizeActive?
Section titled “isMaximizeActive?”boolean = false
Returns
Section titled “Returns”Dialog
setCookiePath()
Section titled “setCookiePath()”setCookiePath(
cookiePath):Dialog
Defined in: window/dialog.ts:242
param: (cookiePath: string)
return: Dialog
Sets the cookie Path of the dialog.
Chainable.
Parameters
Section titled “Parameters”cookiePath
Section titled “cookiePath”string
Returns
Section titled “Returns”Dialog
setSize()
Section titled “setSize()”setSize(
width?,height?):Dialog
Defined in: window/dialog.ts:172
param: (width: number, height: number)
return: Dialog
Sets the size in pixels of the dialog to be displayed.
Chainable.
Parameters
Section titled “Parameters”width?
Section titled “width?”number = 300
height?
Section titled “height?”number = 300
Returns
Section titled “Returns”Dialog
setTitle()
Section titled “setTitle()”setTitle(
title):Dialog
Defined in: window/dialog.ts:186
param: (title: string)
return: Dialog
Sets the title of the dialog to be displayed.
Chainable.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Dialog
show()
Section titled “show()”show():
Promise<Dialog>
Defined in: window/dialog.ts:258
return: Promise
After configuring the dialog, call this function to spawn it.
Chainable.
Returns
Section titled “Returns”Promise<Dialog>
showWithJS()
Section titled “showWithJS()”showWithJS(
script):Promise<Dialog>
Defined in: window/dialog.ts:301
param: (script: string)
return: Promise
After configuring the dialog, call this function to spawn it. A javascript string parameter can be passed to have more control over the dialog
Chainable.
Parameters
Section titled “Parameters”script
Section titled “script”string
Returns
Section titled “Returns”Promise<Dialog>
createAutoDialog()
Section titled “createAutoDialog()”
staticcreateAutoDialog(url):Dialog
Defined in: window/dialog.ts:126
param: (url: string)
return: Dialog
Creates a Dialog object pointing to a URL, that autocloses on an outside
click. AutoDialogs only have access to the setSize and show methods.
Chainable.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Dialog
createDialog()
Section titled “createDialog()”
staticcreateDialog(url):Dialog
Defined in: window/dialog.ts:110
param: (url: string)
return: Dialog
Creates a Dialog object pointing to a URL. Call the other methods to
modify the dialog’s properties, and show() to spawn the dialog.
Chainable.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”Dialog
return()
Section titled “return()”
staticreturn(result?):Promise<any>
Defined in: window/dialog.ts:150
param: (result ?: string)
Closes this dialog with an optional string result. For more complex return values, try JSON.stringify. (Call this method from the dialog.)
As an alternative, lightweight dialogs that do not want to include xjs.js may simply call native XBC methods to return a value.
external.SetDialogResult(stringResult);external.Close();Parameters
Section titled “Parameters”result?
Section titled “result?”string
Returns
Section titled “Returns”Promise<any>