mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Draggable demo: Updated the events demo.
This commit is contained in:
parent
b15af6a193
commit
c5d029e83c
@ -12,41 +12,34 @@
|
|||||||
<link rel="stylesheet" href="../demos.css">
|
<link rel="stylesheet" href="../demos.css">
|
||||||
<style>
|
<style>
|
||||||
#draggable { width: 16em; padding: 0 1em; }
|
#draggable { width: 16em; padding: 0 1em; }
|
||||||
#draggable ul li { margin: 1em 0; padding: 0.5em 0; } * html #draggable ul li { height: 1%; }
|
#draggable li { margin: 1em 0; padding: 0.5em 0; }
|
||||||
#draggable ul li span.ui-icon { float: left; }
|
* html #draggable ul li { height: 1%; }
|
||||||
#draggable ul li span.count { font-weight: bold; }
|
#draggable li .ui-icon { float: left; }
|
||||||
|
#draggable li .count { font-weight: bold; }
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
var $start_counter = $( "#event-start" ),
|
var startCount = $( "#event-start .count" ),
|
||||||
$drag_counter = $( "#event-drag" ),
|
dragCount = $( "#event-drag .count" ),
|
||||||
$stop_counter = $( "#event-stop" ),
|
stopCount = $( "#event-stop .count" );
|
||||||
counts = [ 0, 0, 0 ];
|
|
||||||
|
|
||||||
$( "#draggable" ).draggable({
|
$( "#draggable" ).draggable({
|
||||||
start: function() {
|
start: function() {
|
||||||
counts[ 0 ]++;
|
startCount.text(function( i, current ) {
|
||||||
updateCounterStatus( $start_counter, counts[ 0 ] );
|
return parseInt( current, 10 ) + 1;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
drag: function() {
|
drag: function() {
|
||||||
counts[ 1 ]++;
|
dragCount.text(function( i, current ) {
|
||||||
updateCounterStatus( $drag_counter, counts[ 1 ] );
|
return parseInt( current, 10 ) + 1;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
stop: function() {
|
stop: function() {
|
||||||
counts[ 2 ]++;
|
stopCount.text(function( i, current ) {
|
||||||
updateCounterStatus( $stop_counter, counts[ 2 ] );
|
return parseInt( current, 10 ) + 1;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function updateCounterStatus( $event_counter, new_count ) {
|
|
||||||
// first update the status visually...
|
|
||||||
if ( !$event_counter.hasClass( "ui-state-hover" ) ) {
|
|
||||||
$event_counter.addClass( "ui-state-hover" )
|
|
||||||
.siblings().removeClass( "ui-state-hover" );
|
|
||||||
}
|
|
||||||
// ...then update the numbers
|
|
||||||
$( "span.count", $event_counter ).text( new_count );
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
Loading…
Reference in New Issue
Block a user