I’ve rebuilt the Dock.dialog()
method a little bit. Now the dialog has these options available:
let dialog = Dock.dialog({
html: '',
id: '',
css: '',
okCallback: null,
cancelCallback: null,
okLabel: 'OK',
cancelLabel: 'Cancel',
afterCreateCallback: null,
destroyAfterClosing: false,
width: 200
})
Most of the options are the same, as in the previous version, but the new ones are:
afterCreateCallback
- which allows you to, e.g. assign events to nodes in the dialog
destroyAfterClosing
- if set to true
removes the whole dialog node from the DOM tree, so if you hide()
the dialog and try to show()
it again, it want be posssible
width
- self explanatory.
There’s also an overlay behind each dialog. The overlay blocks user from interacting with the background while the dialog is opened. Clicking on the overlay will have the same effect as closing the dialog via Cancel button.
Added new static method called getShareableUrl()
.
It returns an URL, which you can share with others. Basically, same as the Share button, but now you can generate your own links, without calling the Share dialog.
Added new static method called getRootIdByCurrentCoords(callback)
.
It’s just a shortcut for getting segment by coords and the getting root by segment.
The fetch
event is now also called, when the fetch()
method was aborted. In both cases (success and abort) the event.detail now contains a boolean field called success
and in the case of abort, there’s also a field called message
.
You don’t have to .catch()
errors manually, just check the success
field and act accordingly.
Method .getRootId()
now returns an AbortController
, so you can abort your request, if you want, e.g.:
let request = Dock.getRootId('123456', rootId => console.log(rootId))
request.abort() // the request won't be continued after this line
I wanted to do it also for .getSegmentId()
, but this method uses a link from a different domain, so I had to use GM_xmlhttpRequest()
function (with appropriate grants) and it doesn’t have any way to be aborted (AFAIK).