make sure you can drag a text list item by an editable cell

This commit is contained in:
rlx 2011-11-08 11:06:00 +00:00
parent 243614cee2
commit 33ec75122b

View file

@ -805,10 +805,9 @@ Ox.List = function(options, self) {
}
function mousedown(data) {
var pos = findItemPosition(data),
$cell, clickable, editable;
//self.hadFocus = that.hasFocus();
var pos = findItemPosition(data);
that.gainFocus();
self.mousedownOnSelectedCell = false;
if (pos > -1) {
if (data.metaKey) {
if (!isSelected(pos) && (self.options.max == -1 || self.options.max > self.selected.length)) {
@ -827,20 +826,16 @@ Ox.List = function(options, self) {
// click on unselected item
select(pos);
} else if (self.options.type == 'text') {
$cell = findCell(data);
if ($cell) {
clickable = $cell.is('.OxClickable');
editable = $cell.is('.OxEditable') && !$cell.is('.OxEdit');
if (clickable || editable) {
// click on a clickable or editable cell
triggerClickEvent(clickable ? 'click' : 'edit', self.$items[pos], $cell);
}
}
// click on a selected text list cell
self.mousedownOnSelectedCell = true;
}
} else if (!$(data.target).is('.OxToggle') && self.options.min == 0) {
// click on empty area
selectNone();
}
// note: we have to save if the mousedown was on a selected cell
// since otherwise, mousedown would select a previously unselected item,
// and the subsequent singleclick might trigger an unwanted edit event.
}
function movestart(data) {
@ -892,10 +887,10 @@ Ox.List = function(options, self) {
}
function singleclick(data) {
// this can't trigger on mousedown,
// since it could be a doubleclick
// these can't trigger on mousedown, since the mousedown
// could still be the start of a doubleclick or drag
var pos = findItemPosition(data),
clickable, editable;
$cell, clickable, editable;
if (pos > -1) {
if (
!data.metaKey && !data.shiftKey
@ -903,6 +898,16 @@ Ox.List = function(options, self) {
) {
// click on one of multiple selected items
select(pos);
} else if (self.mousedownOnSelectedCell) {
$cell = findCell(data);
if ($cell) {
clickable = $cell.is('.OxClickable');
editable = $cell.is('.OxEditable') && !$cell.is('.OxEdit');
if (clickable || editable) {
// click on a clickable or editable cell
triggerClickEvent(clickable ? 'click' : 'edit', self.$items[pos], $cell);
}
}
}
}
}