simplify event passing in Ox.List derivatives

This commit is contained in:
rolux 2012-06-30 11:20:37 +02:00
parent 91275f7171
commit 7df61a8ac9
4 changed files with 20 additions and 23 deletions

View file

@ -102,12 +102,10 @@ Ox.IconList = function(options, self) {
sort: self.options.sort,
type: 'icon',
unique: self.options.unique
}, Ox.extend(Ox.clone(self), {updateCallbacks: []})) // pass event handler
})
.addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation))
.bindEvent({
select: function() {
self.options.selected = that.$element.options('selected');
}
.bindEvent(function(data, event) {
that.triggerEvent(event, data);
})
);

View file

@ -77,12 +77,10 @@ Ox.InfoList = function(options, self) {
sort: self.options.sort,
type: 'info',
unique: self.options.unique
}, Ox.extend(Ox.clone(self), {updateCallbacks: []})) // pass event handler
})
.addClass('OxInfoList')
.bindEvent({
select: function() {
self.options.selected = that.$element.options('selected');
}
.bindEvent(function(data, event) {
that.triggerEvent(event, data);
})
);

View file

@ -253,7 +253,7 @@ Ox.TableList = function(options, self) {
sums: self.options.sums,
type: 'text',
unique: self.options.unique
}, Ox.extend(Ox.clone(self), {updateCallbacks: []})) // pass event handler
})
.addClass('OxBody')
.css({
top: (self.options.columnsVisible ? 16 : 0) + 'px',
@ -266,15 +266,13 @@ Ox.TableList = function(options, self) {
that.$head && that.$head.scrollLeft(scrollLeft);
}
})
.bindEvent({
cancel: function(data) {
.bindEvent(function(data, event) {
if (event == 'cancel') {
Ox.Log('List', 'cancel edit', data);
},
edit: function(data) {
} else if (event == 'edit') {
that.editCell(data.id, data.key);
},
select: function() {
self.options.selected = that.$body.options('selected');
} else {
that.triggerEvent(event, data);
}
})
.appendTo(that);

View file

@ -62,16 +62,19 @@ Ox.TreeList = function(options, self) {
max: self.options.max,
min: self.options.min,
unique: 'id'
}, Ox.extend(Ox.clone(self), {updateCallbacks: []})) // pass event handler
})
.addClass('OxTableList OxTreeList')
.css({
width: self.options.width + 'px',
overflowY: 'scroll'
})
.bindEvent({
anyclick: clickItem,
select: selectItem,
toggle: toggleItems
.bindEvent(function(data, event) {
if (event == 'anyclick') {
clickItem(data);
} else if (event == 'toggle') {
toggleItems(data);
}
that.triggerEvent(event, data);
})
);