2011-11-23 17:03:09 +00:00
|
|
|
(function( $, undefined ) {
|
|
|
|
|
|
|
|
var interaction; // = $.ui.interaction
|
|
|
|
|
|
|
|
$.widget( "ui.interaction", {
|
|
|
|
version: "@VERSION",
|
|
|
|
_create: function() {
|
|
|
|
for ( var hook in interaction.hooks ) {
|
|
|
|
interaction.hooks[ hook ].setup( this, this._startProxy( hook ) );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
_startProxy: function( hook ) {
|
|
|
|
var that = this;
|
2012-01-09 02:48:53 +00:00
|
|
|
return function( event, position ) {
|
|
|
|
that._interactionStart( event, position, hook );
|
2011-11-23 17:03:09 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-01-09 02:48:53 +00:00
|
|
|
_interactionStart: function( event, position, hook ) {
|
|
|
|
if ( false !== this._start( event, position ) ) {
|
2011-11-23 17:03:09 +00:00
|
|
|
interaction.started = true;
|
|
|
|
interaction.hooks[ hook ].handle( this );
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2012-01-09 02:48:53 +00:00
|
|
|
_interactionMove: function( event, position ) {
|
|
|
|
this._move( event, position );
|
2011-11-23 17:03:09 +00:00
|
|
|
},
|
|
|
|
|
2012-01-09 02:48:53 +00:00
|
|
|
_interactionStop: function( event, position ) {
|
|
|
|
this._stop( event, position );
|
2011-11-23 17:03:09 +00:00
|
|
|
interaction.started = false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
interaction = $.ui.interaction;
|
|
|
|
$.extend( interaction, {
|
|
|
|
started: false,
|
|
|
|
hooks: {}
|
|
|
|
});
|
|
|
|
|
|
|
|
interaction.hooks.mouse = {
|
|
|
|
setup: function( widget, start ) {
|
|
|
|
widget._bind({
|
|
|
|
"mousedown": function( event ) {
|
|
|
|
if ( event.which === 1 ) {
|
|
|
|
event.preventDefault();
|
2012-01-09 02:48:53 +00:00
|
|
|
start( event, {
|
|
|
|
left: event.pageX,
|
|
|
|
top: event.pageY
|
|
|
|
});
|
2011-11-23 17:03:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
handle: function( widget ) {
|
2012-01-08 01:49:49 +00:00
|
|
|
function mousemove( event ) {
|
|
|
|
event.preventDefault();
|
2012-01-09 02:48:53 +00:00
|
|
|
widget._interactionMove( event, {
|
|
|
|
left: event.pageX,
|
|
|
|
top: event.pageY
|
|
|
|
});
|
2012-01-08 01:49:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function mouseup( event ) {
|
2012-01-09 02:48:53 +00:00
|
|
|
widget._interactionStop( event, {
|
|
|
|
left: event.pageX,
|
|
|
|
top: event.pageY
|
|
|
|
});
|
2012-01-08 01:49:49 +00:00
|
|
|
widget.document
|
|
|
|
.unbind( "mousemove", mousemove )
|
|
|
|
.unbind( "mouseup", mouseup );
|
|
|
|
}
|
|
|
|
|
2011-11-23 17:03:09 +00:00
|
|
|
widget._bind( widget.document, {
|
2012-01-08 01:49:49 +00:00
|
|
|
"mousemove": mousemove,
|
|
|
|
"mouseup": mouseup
|
2011-11-23 17:03:09 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
})( jQuery );
|