1
0
Fork 0
forked from 0x2620/oxjs

use new-style mouse events in Ox.List

This commit is contained in:
rlx 2011-09-03 23:04:18 +00:00
commit be3b1d573d
8 changed files with 185 additions and 143 deletions

View file

@ -104,7 +104,7 @@ Ox.Element = function(options, self) {
function bind(action, event, fn) {
self.$eventHandler[action]('ox_' + event, function(event, data) {
// fixme: remove second parameter
// fixme: remove second parameter (legacy)
fn(Ox.extend({
_element: that.$element,
_event: event
@ -147,14 +147,22 @@ Ox.Element = function(options, self) {
clientX = e.clientX;
clientY = e.clientY;
that.triggerEvent('dragstart', e);
$('*').bind({
mouseenter: dragenter,
mouseleave: dragleave
});
mouserepeat();
mouseInterval = setInterval(mouserepeat, 50);
Ox.UI.$window.unbind('mouseup', mouseup)
.mousemove(mousemove)
.one('mouseup', function(e) {
clearInterval(mouseInterval);
clearTimeout(dragTimeout);
clearTimeout(dragTimeout);
Ox.UI.$window.unbind('mousemove', mousemove);
$('*').unbind({
mouseenter: dragenter,
mouseleave: dragleave
});
that.triggerEvent('dragend', extend(e));
});
that.one('mouseleave', function() {
@ -169,6 +177,12 @@ Ox.Element = function(options, self) {
that.triggerEvent('doubleclick', e);
}
Ox.UI.$window.one('mouseup', mouseup);
function dragenter(e) {
that.triggerEvent('dragenter', e);
}
function dragleave(e) {
that.triggerEvent('dragleave', e);
}
function extend(e) {
return Ox.extend({
clientDX: e.clientX - clientX,
@ -336,7 +350,9 @@ Ox.Element = function(options, self) {
Ox.forEach(Ox.makeObject(arguments), function(data, event) {
if ([
'mousedown', 'mouserepeat', 'anyclick', 'singleclick', 'doubleclick',
'dragstart', 'drag', 'dragpause', 'dragend', 'playing', 'position', 'progress'
'dragstart', 'drag', 'dragenter', 'dragleave', 'dragpause', 'dragend',
'draganddropstart', 'draganddrop', 'draganddropenter', 'draganddropleave', 'draganddropend',
'playing', 'position', 'progress'
].indexOf(event) == -1) {
Ox.print(that.id, self.options.id, 'trigger', event, data);
}