|
1 <!DOCTYPE html> |
|
2 <html lang="en"> |
|
3 <head> |
|
4 <meta charset="UTF-8" /> |
|
5 <title>jQuery UI Droppable - Visual feedback</title> |
|
6 <link type="text/css" href="../../themes/base/jquery.ui.all.css" rel="stylesheet" /> |
|
7 <script type="text/javascript" src="../../jquery-1.4.2.js"></script> |
|
8 <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script> |
|
9 <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script> |
|
10 <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script> |
|
11 <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script> |
|
12 <script type="text/javascript" src="../../ui/jquery.ui.droppable.js"></script> |
|
13 <link type="text/css" href="../demos.css" rel="stylesheet" /> |
|
14 <style type="text/css"> |
|
15 #draggable, #draggable2 { width: 90px; height: 90px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; } |
|
16 #droppable, #droppable2 { width: 120px; height: 120px; padding: 0.5em; float: left; margin: 10px; } |
|
17 </style> |
|
18 <script type="text/javascript"> |
|
19 $(function() { |
|
20 $("#draggable").draggable(); |
|
21 $("#droppable").droppable({ |
|
22 hoverClass: 'ui-state-active', |
|
23 drop: function(event, ui) { |
|
24 $(this).addClass('ui-state-highlight').find('p').html('Dropped!'); |
|
25 } |
|
26 }); |
|
27 |
|
28 $("#draggable2").draggable(); |
|
29 $("#droppable2").droppable({ |
|
30 accept: "#draggable2", |
|
31 activeClass: 'ui-state-hover', |
|
32 drop: function(event, ui) { |
|
33 $(this).addClass('ui-state-highlight').find('p').html('Dropped!'); |
|
34 } |
|
35 }); |
|
36 |
|
37 }); |
|
38 </script> |
|
39 </head> |
|
40 <body> |
|
41 <div class="demo"> |
|
42 |
|
43 <h3 class="docs">Feedback on hover:</h3> |
|
44 |
|
45 <div id="draggable" class="ui-widget-content"> |
|
46 <p>Drag me to my target</p> |
|
47 </div> |
|
48 |
|
49 <div id="droppable" class="ui-widget-header"> |
|
50 <p>Drop here</p> |
|
51 </div> |
|
52 |
|
53 <h3 class="docs">Feedback on activating draggable:</h3> |
|
54 |
|
55 <div id="draggable2" class="ui-widget-content"> |
|
56 <p>Drag me to my target</p> |
|
57 </div> |
|
58 |
|
59 <div id="droppable2" class="ui-widget-header"> |
|
60 <p>Drop here</p> |
|
61 </div> |
|
62 |
|
63 <!-- add active class demo --> |
|
64 |
|
65 </div><!-- End demo --> |
|
66 |
|
67 <div class="demo-description"> |
|
68 |
|
69 <p>Change the droppable's appearance on hover, or when the droppable is active (an acceptable draggable is dropped on it). Use the <code>hoverClass</code> or <code>activeClass</code> options to specify respective classes.</p> |
|
70 |
|
71 </div><!-- End demo-description --> |
|
72 </body> |
|
73 </html> |