File: dragdrop6_test.html

package info (click to toggle)
scriptaculous 1.9.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 952 kB
  • sloc: javascript: 8,533; makefile: 2
file content (76 lines) | stat: -rw-r--r-- 2,366 bytes parent folder | download | duplicates (7)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>script.aculo.us Drag and drop functional test file</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../../lib/prototype.js" type="text/javascript"></script>
  <script src="../../src/scriptaculous.js" type="text/javascript"></script>
  <script src="../../src/unittest.js" type="text/javascript"></script>
  <style type="text/css" media="screen">
    div.box { background: green; width:100px; height:100px }
    div.box-container { background: yellow; width:200px; height:200px }
  </style>
</head>
<body>
<h1>script.aculo.us Drag and drop functional test file</h1>

<h2>Draggables/Droppables</h2>

<div id="box-normal" class="box">
  Normal box
</div>

<div id="box-grid-numeric" class="box">
  snap: 25
</div>

<div id="box-grid-array" class="box">
  snap: [5,25]
</div>

<div id="box-grid-procedural" class="box">
  snap: procedural (e.g. constrain to box)
</div>

<div class="box-container">
  <div id="box-grid-procedural-gets-draggable" class="box">
    snap: procedural (e.g. constrain to parent element)
  </div>
</div>

<script type="text/javascript" language="javascript" charset="utf-8">
// <![CDATA[
  new Draggable('box-normal',{snap:false,revert:true});
  new Draggable('box-grid-numeric',{snap:25,revert:true});
  new Draggable('box-grid-array',{snap:[5,25],revert:true});
  new Draggable('box-grid-procedural',{
    snap: function(x,y) {
      return[
        x<100 ? (x > 0 ? x : 0 ) : 100,
        y<50 ? (y > 0 ? y : 0) : 50];
    },
    revert:true
  });
  new Draggable('box-grid-procedural-gets-draggable',{
    snap: function(x,y,draggable) {
      function constrain(n, lower, upper) {
        if (n > upper) return upper;
        else if (n < lower) return lower;
        else return n;
      }
     
      element_dimensions = Element.getDimensions(draggable.element);
      parent_dimensions = Element.getDimensions(draggable.element.parentNode);
      return[
        constrain(x, 0, parent_dimensions.width - element_dimensions.width),
        constrain(y, 0, parent_dimensions.height - element_dimensions.height)];
    },
    revert:true
  });
// ]]>
</script>


</body>
</html>