dialogus.js
fileIt should export a dialogus
object that is an instance of EventTarget
with the following methods:
Also dialogus
object is expected to dispatch the following custom events:
splashtrigger
addnodetrigger
addlinktrigger
savenodetrigger
savelinktrigger
deletenodetrigger
deletelinktrigger
swapdirectionstrigger
init()
open(name, ?data)
This function (method) is to be used for side effects only. It should open the dialog with the given name
. If data
is provided, it should be used to prepare the dialog.
If data.canClose
is true
, the dialog buttons like Cancel
, Close
, Continue
and OK
(class close
) should close the dialog until it is closed once. Also the dialog should be closed if the user clicks outside of it or presses the ESC
key. But again, only until the dialog is closed once.
It supposed to recognize the following dialog names:
menu
splash
inform
new node
edit node
delete node
new link
edit link
delete link
close(name)
This function (method) is to be used for side effects only. It should close the dialog with the given name
.
It supposed to recognize the same dialog names as open(...)
.
swapDirections(name)
This function (method) is to be used for side effects only. It should swap the values in the from
and to
fields of the dialog with the given name
.
It supposed to recognize the following dialog names:
new link
edit link
splashtigger
This event should be dispatched when the “About” button is clicked in “Menu” dialog.
addnodetrigger
This event should be dispatched when the “Add” button is clicked in “Add node” dialog. It should carry the event.detail.node
object of the following shape:
{
name: trimmed string,
description: trimmed string,
}
addlinktrigger
This event should be dispatched when the “Add” button is clicked in “Add Link” dialog. It should carry the event.detail.link
object of the following shape:
{
from: trimmed string,
to: trimmed string,
description: trimmed string,
}
savelinktrigger
This event should be dispatched when the “Save” button is clicked in “Edit link” dialog. It should carry the event.detail.link
object of the following shape:
{
id {
from: positive integer,
to: different positive integer,
},
from: trimmed string,
to: trimmed string,
description: trimmed string,
}
savenodetrigger
This event should be dispatched when the “Save” button is clicked in “Edit node” dialog. It should carry the event.detail.node
object of the following shape:
{
id: positive integer,
name: trimmed string,
description: trimmed string,
}
deletenodetrigger
This event should be dispatched when the “Delete” button is clicked in “Delete node” dialog. It should contain the node information as event.detail.id
. Right after the event is dispatched, the “Delete node” dialog should be closed.
deletelinktrigger
This event should be dispatched when the “Delete” button is clicked in “Delete link” dialog. It should contain the link information as event.detail.id
object of the following shape:
{
from: positive integer,
to: different positive integer,
}
Right after the event is dispatched, the “Delete link” dialog should be closed.
swapdirectionstrigger
This event should be dispatched when the “Swap” button is clicked in “Add link” or “Edit link” dialog. It should contain the dialog name as event.detail.name
. Dialogus should also listen for this event and call the swapDirections(event.detail.name)
method on itself.