summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/editing/dnd/svg/058.svg
blob: d2bb91da8d36b1e389a51d370d1f028b8e8b434a (plain)
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
<?xml version="1.0" encoding="utf-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="500px" height="500px" viewBox="0 0 500 500">
<title>SVG link drag and drop: allowed effects 'copy','move','link' and 'none'</title>
<a xlink:href="data:text/plain,1">
  <circle cx="50" cy="50" r="40" fill="green"/>
</a>
<textArea x="10" y="100" width="480" height="200" font-size="30">You should be able to drag green circle and drop it onto any of the boxes below. Choosen box should turn green once circle is dropped on it.</textArea>
<rect x="10" y="300" width="100" height="100" fill="silver"/>
<rect x="120" y="300" width="100" height="100" fill="gray"/>
<rect x="230" y="300" width="100" height="100" fill="gray"/>
<rect x="340" y="300" width="100" height="100" fill="black"/>
<script type="application/ecmascript">
var a = document.querySelector('a'), rect = document.querySelectorAll('rect'),
effects = ['copy','move','link','all'], e = 0;
a.addEventListener('dragstart',
function (event)
  {event.dataTransfer.effectAllowed = effects[e]}
,false);
for(var i = 0; i != rect.length; i++)
  {rect[i].addEventListener('dragenter',
  function (event)
    {event.preventDefault();
    event.dataTransfer.effectAllowed = effects[e];}
  ,false);
  rect[i].addEventListener('dragover',
  function (event)
    {event.preventDefault()}
  ,false);
  rect[i].addEventListener('drop',
  function (event)
    {if(event.dataTransfer.dropEffect == effects[e] &amp;&amp; event.dataTransfer.effectAllowed == effects[e] &amp;&amp; i != 3)
      {event.target.setAttribute('fill','green');}
    e = (e+1)%3;}
  ,false);}
</script>
</svg>