fix a bug where clicks and changes in a submenu would not fire on the parent menu

This commit is contained in:
rlx 2011-01-11 15:00:32 +00:00
parent e8be24d20e
commit 9da654ad08

View file

@ -6645,7 +6645,8 @@ requires
var $cell,
$item = findItem(e),
pos,
editTimeout = false;
clickable, editable,
clickTimeout = false;
selectTimeout = false;
that.gainFocus();
if ($item) {
@ -6670,11 +6671,15 @@ requires
selectTimeout = true;
} else if (self.options.type == 'text') {
$cell = findCell(e);
if ($cell && $cell.hasClass('OxEditable') && !$cell.hasClass('OxEdit')) {
if ($cell) {
clickable = $cell.hasClass('OxClickable');
editable = $cell.hasClass('OxEditable') && !$cell.hasClass('OxEdit');
if (clickable || editable) {
if (self.options.sortable) {
editTimeout = true;
clickTimeout = true;
} else {
triggerEditEvent($item, $cell);
triggerCellEvent($item, $cell, clickable ? 'click' : 'edit');
}
}
}
}
@ -6695,8 +6700,8 @@ requires
if (self.dragTimeout) {
clearTimeout(self.dragTimeout);
self.dragTimeout = 0;
if (editTimeout) {
triggerEditEvent($item, $cell);
if (clickTimeout) {
triggerCellEvent($item, $cell, clickable ? 'click' : 'edit');
}
}
});
@ -6932,8 +6937,9 @@ requires
}
}
function triggerEditEvent($item, $cell) {
that.triggerEvent('edit', {
function triggerCellEvent($item, $cell, event) {
// event can be 'click' or 'edit'
that.triggerEvent(event, {
id: $item.data('id'),
key: $cell.attr('class').split('OxColumn')[1].split(' ')[0].toLowerCase()
});
@ -7051,6 +7057,7 @@ requires
that.closePreview = function() {
self.preview = false;
return that;
};
that.reload = function() {
@ -7065,6 +7072,15 @@ requires
that.scrollToSelection = function() {
self.selected.length && scrollToPosition(self.selected[0]);
return that;
};
that.setId = function(oldId, newId) {
var index = self.ids.indexOf(oldId);
if (index > -1) {
self.ids[index] = newId;
}
return that;
};
that.size = function() { // fixme: not a good function name
@ -7099,6 +7115,7 @@ requires
emptyFirstPage();
fillFirstPage();
}
return that;
}
that.sortList = function(key, operator) {
@ -7113,6 +7130,10 @@ requires
return that;
}
that.value = function(id, key, value) {
};
return that;
};
@ -7150,7 +7171,6 @@ requires
.addClass('OxItem')
.attr({
draggable: self.options.draggable
//id: self.options.id.replace(/./g, '_') // fixme: dots are not the only problem
})
.data({
id: self.options.id,
@ -7460,6 +7480,7 @@ requires
var $cell = $('<div>')
.addClass(
'OxCell OxColumn' + Ox.toTitleCase(v.id) +
(v.clickable ? ' OxClickable' : '') +
(v.editable ? ' OxEditable' : '')
)
.css({
@ -7579,6 +7600,7 @@ requires
}
function getCell(id, key) {
Ox.print('getCell', id, key)
var $item = getItem(id);
return $($item.find('.OxCell.OxColumn' + Ox.toTitleCase(key))[0]);
}
@ -7592,6 +7614,7 @@ requires
}
function getItem(id) {
Ox.print('getItem', id)
var $item = null;
$.each(that.find('.OxItem'), function(i, v) {
$v = $(v);
@ -7599,7 +7622,7 @@ requires
$item = $v;
return false;
}
})
});
return $item;
}
@ -7766,9 +7789,17 @@ requires
};
that.value = function(id, key, value) {
// fixme: make this accept id, {k: v, ...}
var $item = getItem(id),
$cell = getCell(id, key);
if (Ox.isUndefined(value)) {
return $cell.html();
} else {
$cell && $cell.html(value);
if (self.options.columns[getColumnIndexById(key)].unique) {
that.$body.setId($item.data('id'), value);
$item.data({id: value});
}
return that;
}
}
@ -8608,6 +8639,7 @@ requires
function clickItem(position) {
var item = that.items[position],
menu = self.options.mainmenu || self.options.parent || that,
toggled;
that.hideMenu();
if (!item.options('items').length) {
@ -8624,7 +8656,7 @@ requires
that.items[pos].toggleChecked();
});
Ox.print('--triggering change event--');
(self.options.mainmenu || that).triggerEvent('change', {
menu.triggerEvent('change', {
id: item.options('group'),
checked: $.map(self.optionGroups[item.options('group')].checked(), function(v, i) {
return {
@ -8636,14 +8668,14 @@ requires
}
} else {
item.toggleChecked();
(self.options.mainmenu || that).triggerEvent('change', {
menu.triggerEvent('change', {
checked: item.options('checked'),
id: item.options('id'),
title: Ox.stripTags(item.options('title')[0])
});
}
} else {
(self.options.mainmenu || that).triggerEvent('click', {
menu.triggerEvent('click', {
id: item.options('id'),
title: Ox.stripTags(item.options('title')[0])
});