Utilities for interacting with the HTML5 drag/drop APIs.
Methods
-
<static> fromClipboard(clipboard)
-
Read data previously written to the clipboard by a call to
toClipboard.Parameters:
Name Type Description clipboardDataTransfer Returns:
promise to be resolved with an
Envelope
instance- Type
- Promise
Example
$('.dropTarget').on('drop', function (e) { dragDropUtils.fromClipboard(e.originalEvent.dataTransfer) .then(function (envelope) { envelope.toValues().then(function (values) { values.forEach(handleValue); }); }); }); -
<static> toClipboard(clipboard, mimeType [, values])
-
Add the given data onto the clipboard.
Parameters:
Name Type Argument Description clipboardDataTransfer the
DataTransferon which to set the datamimeTypeString | module:bajaux/dragdrop/Envelope a supported Niagara mime type for the given data, in which case the given
values will be converted to anEnvelopeinstance; or anEnvelope
instance directlyvaluesArray <optional>
if a mime type given, the values to convert to an
EnvelopeinstanceReturns:
promise to be resolved when the
Envelope
instance has been created or received, and has written JSON data onto the
clipboard- Type
- Promise
Example
$('.dragSource').on('dragstart', function (e) { var dataTransfer = e.originalEvent.dataTransfer; dragDropUtils.toClipboard(dataTransfer, 'niagara/strings', [ 'hello', 'world' ]) .then(function () { console.log('clipboard populated with: ' + dataTransfer.getData('Text')); }); });