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) { function mousedown(data) {
var pos = findItemPosition(data), var pos = findItemPosition(data);
$cell, clickable, editable;
//self.hadFocus = that.hasFocus();
that.gainFocus(); that.gainFocus();
self.mousedownOnSelectedCell = false;
if (pos > -1) { if (pos > -1) {
if (data.metaKey) { if (data.metaKey) {
if (!isSelected(pos) && (self.options.max == -1 || self.options.max > self.selected.length)) { 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 // click on unselected item
select(pos); select(pos);
} else if (self.options.type == 'text') { } else if (self.options.type == 'text') {
$cell = findCell(data); // click on a selected text list cell
if ($cell) { self.mousedownOnSelectedCell = true;
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);
}
}
} }
} else if (!$(data.target).is('.OxToggle') && self.options.min == 0) { } else if (!$(data.target).is('.OxToggle') && self.options.min == 0) {
// click on empty area // click on empty area
selectNone(); 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) { function movestart(data) {
@ -892,10 +887,10 @@ Ox.List = function(options, self) {
} }
function singleclick(data) { function singleclick(data) {
// this can't trigger on mousedown, // these can't trigger on mousedown, since the mousedown
// since it could be a doubleclick // could still be the start of a doubleclick or drag
var pos = findItemPosition(data), var pos = findItemPosition(data),
clickable, editable; $cell, clickable, editable;
if (pos > -1) { if (pos > -1) {
if ( if (
!data.metaKey && !data.shiftKey !data.metaKey && !data.shiftKey
@ -903,6 +898,16 @@ Ox.List = function(options, self) {
) { ) {
// click on one of multiple selected items // click on one of multiple selected items
select(pos); 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);
}
}
} }
} }
} }