From 7df61a8ac95be5d81f452ee1c4b00fe74c264db3 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 30 Jun 2012 11:20:37 +0200 Subject: [PATCH] simplify event passing in Ox.List derivatives --- source/Ox.UI/js/List/IconList.js | 8 +++----- source/Ox.UI/js/List/InfoList.js | 8 +++----- source/Ox.UI/js/List/TableList.js | 14 ++++++-------- source/Ox.UI/js/List/TreeList.js | 13 ++++++++----- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/source/Ox.UI/js/List/IconList.js b/source/Ox.UI/js/List/IconList.js index bae58c4f..5ac09b07 100644 --- a/source/Ox.UI/js/List/IconList.js +++ b/source/Ox.UI/js/List/IconList.js @@ -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); }) ); diff --git a/source/Ox.UI/js/List/InfoList.js b/source/Ox.UI/js/List/InfoList.js index 93ac7eed..73e81b62 100644 --- a/source/Ox.UI/js/List/InfoList.js +++ b/source/Ox.UI/js/List/InfoList.js @@ -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); }) ); diff --git a/source/Ox.UI/js/List/TableList.js b/source/Ox.UI/js/List/TableList.js index 3dd799b3..e2450cc7 100644 --- a/source/Ox.UI/js/List/TableList.js +++ b/source/Ox.UI/js/List/TableList.js @@ -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); diff --git a/source/Ox.UI/js/List/TreeList.js b/source/Ox.UI/js/List/TreeList.js index 3035e8cc..22825b61 100644 --- a/source/Ox.UI/js/List/TreeList.js +++ b/source/Ox.UI/js/List/TreeList.js @@ -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); }) );