source: main/trunk/greenstone3/web/interfaces/oran/js/jquery-ui-1.8rc1/demos/draggable/events.html@ 24245

Last change on this file since 24245 was 24245, checked in by sjb48, 13 years ago

Oran code for supporting format changes to document.

  • Property svn:executable set to *
File size: 2.8 KB
Line 
1<!doctype html>
2<html lang="en">
3<head>
4 <title>jQuery UI Draggable - Events</title>
5 <link type="text/css" href="../../themes/base/ui.all.css" rel="stylesheet" />
6 <script type="text/javascript" src="../../jquery-1.4.1.js"></script>
7 <script type="text/javascript" src="../../ui/jquery.ui.core.js"></script>
8 <script type="text/javascript" src="../../ui/jquery.ui.widget.js"></script>
9 <script type="text/javascript" src="../../ui/jquery.ui.mouse.js"></script>
10 <script type="text/javascript" src="../../ui/jquery.ui.draggable.js"></script>
11 <link type="text/css" href="../demos.css" rel="stylesheet" />
12 <style type="text/css">
13 #draggable { width: 16em; padding: 0 1em; }
14 #draggable ul li { margin: 1em 0; padding: 0.5em 0; } * html #draggable ul li { height: 1%; }
15 #draggable ul li span.ui-icon { float: left; }
16 #draggable ul li span.count { font-weight: bold; }
17 </style>
18 <script type="text/javascript">
19 $(function() {
20 var $start_counter = $('#event-start'), $drag_counter = $('#event-drag'), $stop_counter = $('#event-stop');
21 var counts = [0,0,0];
22
23 $("#draggable").draggable({
24 start: function() {
25 counts[0]++;
26 updateCounterStatus($start_counter,counts[0]);
27 },
28 drag: function() {
29 counts[1]++;
30 updateCounterStatus($drag_counter,counts[1]);
31 },
32 stop: function() {
33 counts[2]++;
34 updateCounterStatus($stop_counter,counts[2]);
35 }
36 });
37 });
38
39 function updateCounterStatus($event_counter,new_count) {
40 // first update the status visually...
41 if (!$event_counter.hasClass('ui-state-hover')) {
42 $event_counter.addClass('ui-state-hover')
43 .siblings().removeClass('ui-state-hover');
44 }
45 // ...then update the numbers
46 $('span.count',$event_counter).text(new_count);
47 }
48 </script>
49</head>
50<body>
51
52<div class="demo">
53
54<div id="draggable" class="ui-widget ui-widget-content">
55
56 <p>Drag me to trigger the chain of events.</p>
57
58 <ul class="ui-helper-reset">
59 <li id="event-start" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-play"></span>"start" invoked <span class="count">0</span>x</li>
60 <li id="event-drag" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-arrow-4"></span>"drag" invoked <span class="count">0</span>x</li>
61 <li id="event-stop" class="ui-state-default ui-corner-all"><span class="ui-icon ui-icon-stop"></span>"stop" invoked <span class="count">0</span>x</li>
62 </ul>
63</div>
64
65</div><!-- End demo -->
66
67<div class="demo-description">
68
69<p>
70Layer functionality onto the draggable using the <code>start</code>, <code>drag</code>, and <code>stop</code> events. Start is fired at the start of the drag; drag during the drag; and stop when dragging stops.
71</p>
72
73</div><!-- End demo-description -->
74
75</body>
76</html>
Note: See TracBrowser for help on using the repository browser.