Skip to content

Commit 9558b95

Browse files
committed
Significant edits to flesh out the text 📝
1 parent dbd7185 commit 9558b95

File tree

1 file changed

+43
-15
lines changed

1 file changed

+43
-15
lines changed

recipe/0599-drag-and-drop/index.md

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,36 +13,64 @@ topic:
1313

1414
As a person wanting to annotate a IIIF resource, you would like to open a manifest in a viewer not available in the web interface where you first find the resource.
1515

16+
Alternately, as a viewer developer, you would like to allow your viewer to accept manifests from dragged-over items.
17+
1618
## Implementation Notes
1719

18-
Implementing this recipe requires a resource provider and a viewer provider each to implement their part. The resource provider must have a draggable item that can have a `dataTransfer.setData` method attached to the item's `dragstart` event and the viewer provider must have an interface capable of handling the data in its `drop` event.
20+
Implementing this recipe requires a resource provider and a viewer each to implement their part.
21+
22+
### For Resource Providers
23+
24+
The resource provider must have a draggable item — such as an image — that makes use of the DataTransfer object. It will have a [`dataTransfer.setData` method](https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer) attached to the item's `dragstart` event.
25+
26+
### For Viewer Developers
27+
28+
A supporting viewer must have an interface capable of handling the DataTransfer object's data carried by the draggable item in its `drop` event.
1929

2030
## Restrictions
2131

2232
Because implementation is two-part, you may only have control over one half of the ability to drag and drop. Consequently, and since this action is only in a GUI environment, you will need to consider whether visitors to your IIIF interface would benefit from some kind of support text.
2333

34+
Viewer developers will have a special need to consider security when implementing a droppable interface.
35+
2436
## Example
2537

26-
Describe the solution in prose and provide an example.
27-
The example json document must be an external document, and imported with the following:
38+
Below are a link to this recipe's Manifest, an image of the IIIF logo decorated with the appropriate JavaScript event handler attributes, and a visible version of the script called by the image's event handlers. For a supporting viewer, the IIIF logo image below could be dragged onto its viewing area and dropped, which would result in the viewer retrieving the manifest for the IIIF Cookbook recipe titled ["Internationalization and Multi-language Values"][0006].
2839

2940
{% include manifest_links.html viewers="" manifest="manifest.json" %}
3041

3142
<img src="https://iiif.io/api/cookbook/assets/images/logos/logo-sm.png" draggable="true" ondragstart="drag(event)" alt="IIIF logo; drag and drop onto a supporting viewer to see this resource in that viewer">
3243

44+
```
45+
<script>
46+
function drag(ev) {
47+
ev.dataTransfer.setData("text/plain", JSON.stringify({
48+
"@context": "http://iiif.io/api/presentation/3/context.json",
49+
"id": "https://iiif.io/api/cookbook/recipe/0599-drag-and-drop/dnd-manifest.json",
50+
"type": "Annotation",
51+
"motivation": ["contentState"],
52+
"target": {
53+
"id": "https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json",
54+
"type": "Manifest"
55+
}
56+
}));
57+
}
58+
</script>
59+
```
60+
3361
<script>
34-
function drag(ev) {
35-
ev.dataTransfer.setData("text/plain", JSON.stringify({
36-
"@context": "http://iiif.io/api/presentation/3/context.json",
37-
"id": "https://example.org/content-states/1",
38-
"type": "Annotation",
39-
"motivation": ["contentState"],
40-
"target": {
41-
"id": "https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json",
42-
"type": "Manifest"
43-
}
44-
}));
45-
}
62+
function drag(ev) {
63+
ev.dataTransfer.setData("text/plain", JSON.stringify({
64+
"@context": "http://iiif.io/api/presentation/3/context.json",
65+
"id": "https://iiif.io/api/cookbook/recipe/0599-drag-and-drop/dnd-manifest.json",
66+
"type": "Annotation",
67+
"motivation": ["contentState"],
68+
"target": {
69+
"id": "https://iiif.io/api/cookbook/recipe/0006-text-language/manifest.json",
70+
"type": "Manifest"
71+
}
72+
}));
73+
}
4674
</script>
4775

4876
## Related Recipes

0 commit comments

Comments
 (0)