annotate jquery-ui/development-bundle/demos/droppable/shopping-cart.html @ 0:b2e4605f20b2

beta version
author dwinter
date Thu, 30 Jun 2011 09:07:49 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
1 <!DOCTYPE html>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
2 <html lang="en">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
3 <head>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
4 <meta charset="utf-8">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
5 <title>jQuery UI Droppable - Shopping Cart Demo</title>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
6 <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
7 <script src="../../jquery-1.5.1.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
8 <script src="../../ui/jquery.ui.core.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
9 <script src="../../ui/jquery.ui.widget.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
10 <script src="../../ui/jquery.ui.mouse.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
11 <script src="../../ui/jquery.ui.draggable.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
12 <script src="../../ui/jquery.ui.droppable.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
13 <script src="../../ui/jquery.ui.sortable.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
14 <script src="../../ui/jquery.ui.accordion.js"></script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
15 <link rel="stylesheet" href="../demos.css">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
16 <style>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
17 h1 { padding: .2em; margin: 0; }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
18 #products { float:left; width: 500px; margin-right: 2em; }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
19 #cart { width: 200px; float: left; }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
20 /* style the list to maximize the droppable hitarea */
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
21 #cart ol { margin: 0; padding: 1em 0 1em 3em; }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
22 </style>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
23 <script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
24 $(function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
25 $( "#catalog" ).accordion();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
26 $( "#catalog li" ).draggable({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
27 appendTo: "body",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
28 helper: "clone"
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
29 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
30 $( "#cart ol" ).droppable({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
31 activeClass: "ui-state-default",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
32 hoverClass: "ui-state-hover",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
33 accept: ":not(.ui-sortable-helper)",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
34 drop: function( event, ui ) {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
35 $( this ).find( ".placeholder" ).remove();
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
36 $( "<li></li>" ).text( ui.draggable.text() ).appendTo( this );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
37 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
38 }).sortable({
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
39 items: "li:not(.placeholder)",
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
40 sort: function() {
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
41 // gets added unintentionally by droppable interacting with sortable
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
42 // using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
43 $( this ).removeClass( "ui-state-default" );
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
44 }
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
45 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
46 });
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
47 </script>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
48 </head>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
49 <body>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
50
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
51 <div class="demo">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
52
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
53 <div id="products">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
54 <h1 class="ui-widget-header">Products</h1>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
55 <div id="catalog">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
56 <h3><a href="#">T-Shirts</a></h3>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
57 <div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
58 <ul>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
59 <li>Lolcat Shirt</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
60 <li>Cheezeburger Shirt</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
61 <li>Buckit Shirt</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
62 </ul>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
63 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
64 <h3><a href="#">Bags</a></h3>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
65 <div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
66 <ul>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
67 <li>Zebra Striped</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
68 <li>Black Leather</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
69 <li>Alligator Leather</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
70 </ul>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
71 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
72 <h3><a href="#">Gadgets</a></h3>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
73 <div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
74 <ul>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
75 <li>iPhone</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
76 <li>iPod</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
77 <li>iPad</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
78 </ul>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
79 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
80 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
81 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
82
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
83 <div id="cart">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
84 <h1 class="ui-widget-header">Shopping Cart</h1>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
85 <div class="ui-widget-content">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
86 <ol>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
87 <li class="placeholder">Add your items here</li>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
88 </ol>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
89 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
90 </div>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
91
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
92 </div><!-- End demo -->
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
93
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
94
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
95
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
96 <div class="demo-description">
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
97 <p>Demonstrate how to use an accordion to structure products into a catalog and make use drag and drop for adding them to a shopping cart, where they are sortable.</p>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
98 </div><!-- End demo-description -->
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
99
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
100 </body>
b2e4605f20b2 beta version
dwinter
parents:
diff changeset
101 </html>