root/public/javascripts/scriptaculous/test/functional/dragdrop6_test.html @ 11

Revision 1, 2.3 kB (checked in by falcon, 17 years ago)

Version one -> initial work from the laptop.

Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4<head>
5  <title>script.aculo.us Drag and drop functional test file</title>
6  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
7  <script src="../../lib/prototype.js" type="text/javascript"></script>
8  <script src="../../src/scriptaculous.js" type="text/javascript"></script>
9  <script src="../../src/unittest.js" type="text/javascript"></script>
10  <style type="text/css" media="screen">
11    div.box { background: green; width:100px; height:100px }
12    div.box-container { background: yellow; width:200px; height:200px }
13  </style>
14</head>
15<body>
16<h1>script.aculo.us Drag and drop functional test file</h1>
17
18<h2>Draggables/Droppables</h2>
19
20<div id="box-normal" class="box">
21  Normal box
22</div>
23
24<div id="box-grid-numeric" class="box">
25  snap: 25
26</div>
27
28<div id="box-grid-array" class="box">
29  snap: [5,25]
30</div>
31
32<div id="box-grid-procedural" class="box">
33  snap: procedural (e.g. constrain to box)
34</div>
35
36<div class="box-container">
37  <div id="box-grid-procedural-gets-draggable" class="box">
38    snap: procedural (e.g. constrain to parent element)
39  </div>
40</div>
41
42<script type="text/javascript" language="javascript" charset="utf-8">
43// <![CDATA[
44  new Draggable('box-normal',{snap:false,revert:true});
45  new Draggable('box-grid-numeric',{snap:25,revert:true});
46  new Draggable('box-grid-array',{snap:[5,25],revert:true});
47  new Draggable('box-grid-procedural',{
48    snap: function(x,y) {
49      return[
50        x<100 ? (x > 0 ? x : 0 ) : 100,
51        y<50 ? (y > 0 ? y : 0) : 50];
52    },
53    revert:true
54  });
55  new Draggable('box-grid-procedural-gets-draggable',{
56    snap: function(x,y,draggable) {
57      function constrain(n, lower, upper) {
58        if (n > upper) return upper;
59        else if (n < lower) return lower;
60        else return n;
61      }
62     
63      element_dimensions = Element.getDimensions(draggable.element);
64      parent_dimensions = Element.getDimensions(draggable.element.parentNode);
65      return[
66        constrain(x, 0, parent_dimensions.width - element_dimensions.width),
67        constrain(y, 0, parent_dimensions.height - element_dimensions.height)];
68    },
69    revert:true
70  });
71// ]]>
72</script>
73
74
75</body>
76</html>
Note: See TracBrowser for help on using the browser.