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, sort: self.options.sort,
type: 'icon', type: 'icon',
unique: self.options.unique unique: self.options.unique
}, Ox.extend(Ox.clone(self), {updateCallbacks: []})) // pass event handler })
.addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation)) .addClass('OxIconList Ox' + Ox.toTitleCase(self.options.orientation))
.bindEvent({ .bindEvent(function(data, event) {
select: function() { that.triggerEvent(event, data);
self.options.selected = that.$element.options('selected');
}
}) })
); );

View file

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

View file

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

View file

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