File: 005.xhtml

package info (click to toggle)
firefox 147.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,484 kB
  • sloc: cpp: 7,607,246; javascript: 6,533,185; ansic: 3,775,227; python: 1,415,393; xml: 634,561; asm: 438,951; java: 186,241; sh: 62,752; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (76 lines) | stat: -rw-r--r-- 3,091 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="support/dropEffect-test-helper.js"></script>
<script src="../resources/test-helper.js"></script>
<head>
  <title>SVG image drag and drop: allowed effects 'copy','move','link'</title>
  <style type="text/css">
    div {
      display: inline-block;
      vertical-align: top;
      background-color: olive;
      color: white;
      padding: 20px;
      width: 100px;
      height: 100px;
    }

    div:nth-child(2) {
      background-color: green;
    }

    div:nth-child(3) {
      background-color: teal;
    }
  </style>
</head>
<body>
  <p>
    Drag these SVG images. Each has a different effectAllowed and color.
  </p>
  <p>
    <img id="copy-drag" ondragstart="event.dataTransfer.effectAllowed = 'copy'"
      src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20version%3D%221.1%22%20width%3D%22100px%22%20height%3D%22100px%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22olive%22/%3E%3C/svg%3E"
      alt="Olive SVG circle for copy" />
    <img id="move-drag" ondragstart="event.dataTransfer.effectAllowed = 'move'"
      src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20version%3D%221.1%22%20width%3D%22100px%22%20height%3D%22100px%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22green%22/%3E%3C/svg%3E"
      alt="Green SVG circle for move" />
    <img id="link-drag" ondragstart="event.dataTransfer.effectAllowed = 'link'"
      src="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20version%3D%221.1%22%20width%3D%22100px%22%20height%3D%22100px%22%20viewBox%3D%220%200%20100%20100%22%3E%3Ccircle%20cx%3D%2250%22%20cy%3D%2250%22%20r%3D%2250%22%20fill%3D%22teal%22/%3E%3C/svg%3E"
      alt="Teal SVG circle for link" />
  </p>
  <p>
    Drop targets for each effect:
  </p>
  <p>
    <div id="copy-drop" ondragover="onDragOver(event, 'copy')">copy</div>
    <div id="move-drop" ondragover="onDragOver(event, 'move')">move</div>
    <div id="link-drop" ondragover="onDragOver(event, 'link')">link</div>
  </p>
</body>
<script>
  function onDragOver(event, effect) {
    event.preventDefault();
    event.dataTransfer.dropEffect = effect;
  }

  async function test() {
    await new Promise(loaded => window.addEventListener("load", loaded));

    for (const effect of ['copy', 'move', 'link']) {
      const dragImage = document.getElementById(effect + '-drag');
      const dropDiv = document.getElementById(effect + '-drop');

      dragDropTest(
        dragImage, dropDiv, dropEffectOnDropCallBack,
        'dropEffect should match effectAllowed on drop for ' + effect);
    }
  }
  test();
</script>
</html>