diff --git a/source/Ox.UI/js/Form/FormPanel.js b/source/Ox.UI/js/Form/FormPanel.js index 52d95faa..e1af6c07 100644 --- a/source/Ox.UI/js/Form/FormPanel.js +++ b/source/Ox.UI/js/Form/FormPanel.js @@ -15,13 +15,15 @@ Ox.FormPanel = function(options, self) { }) .options(options || {}); - self.sections = self.options.form.map(function(section) { - return section.title; - }); self.section = 0; - self.sectionTitle = self.sections[self.section].title; + self.sectionTitle = self.options.form[self.section].title; self.$list = Ox.TextList({ columns: [ + { + id: 'id', + unique: true, + visible: false + }, { format: function(value) { return $('') @@ -42,32 +44,28 @@ Ox.FormPanel = function(options, self) { }, { format: function(value) { - return (getSectionIndexByTitle(value) + 1) + '. ' + value; + return (Ox.indexOf(self.options.form, function(section) { + return section.title == value; + }) + 1) + '. ' + value; }, id: 'title', title: 'Title', - unique: true, visible: true, width: 240 } ], items: self.options.form.map(function(section) { - return {title: section.title, valid: false}; + return {id: section.id, title: section.title, valid: false}; }), max: 1, min: 1, - selected: [self.sections[0].id], + selected: [self.options.form[0].id], sort: [{key: 'id', operator: '+'}], width: 256 }).bindEvent({ select: function(data) { self.$sections[self.section].hide(); - Ox.forEach(self.options.form, function(section, i) { - if (section.title == data.ids[0]) { - self.section = i; - Ox.Break(); - } - }); + self.section = Ox.getIndexById(self.options.form, data.ids[0]); self.$sections[self.section].show(); } }); @@ -101,16 +99,16 @@ Ox.FormPanel = function(options, self) { .bindEvent({ change: function(data) { Ox.Log('FORM', '---CHANGE---', data, self.$forms[i].valid()) - self.$list.value(section.title, 'valid', self.$forms[i].valid()); + self.$list.value(section.id, 'valid', self.$forms[i].valid()); that.triggerEvent('change', { - section: section.title, + section: section.id, data: data }); }, validate: function(data) { - self.$list.value(section.title, 'valid', data.valid); + self.$list.value(section.id, 'valid', data.valid); that.triggerEvent('validate', { - section: section.title, + section: section.id, data: data }); } @@ -121,8 +119,7 @@ Ox.FormPanel = function(options, self) { }); self.$forms.forEach(function($form, i) { - //Ox.print(self.sections[i], 'valid', $form.valid()); - self.$list.value(self.sections[i], 'valid', $form.valid()); + self.$list.value(self.options.form[i].id, 'valid', $form.valid()); }); self.$sections[0].show(); @@ -142,17 +139,6 @@ Ox.FormPanel = function(options, self) { orientation: 'horizontal' }); - function getSectionIndexByTitle(title) { - var index = -1; - Ox.forEach(self.options.form, function(section, i) { - if (section.title == title) { - index = i; - Ox.Break(); - } - }); - return index; - } - /*@ renderPrintVersion renderPrintVersion (title) ->