// vim: et:ts=4:sw=4:sts=4:ft=javascript 'use strict'; /*@ Ox.FormElementGroup FormElementGroup Element () -> FormElementGroup Element (options) -> FormElementGroup Element (options, self) -> FormElementGroup Element options Options object id element id elements elements in group float alignment separators separators (not implemented) width group width self Shared private variable @*/ Ox.FormElementGroup = function(options, self) { self = self || {}; var that = Ox.Element({}, self) .defaults({ id: '', elements: [], float: 'left', separators: [], width: 0 }) .options(options || {}) .addClass('OxInputGroup'); ( self.options.float == 'left' ? self.options.elements : self.options.elements.reverse() ).forEach(function($element, i) { $element.css({ float: self.options.float // fixme: make this a class }) .bindEvent({ autovalidate: function(data) { that.triggerEvent({autovalidate: data}); }, validate: function(data) { that.triggerEvent({validate: data}); } }) .appendTo(that); }); /* if (self.options.width) { setWidths(); } else { self.options.width = getWidth(); } that.css({ width: self.options.width + 'px' }); */ function getWidth() { } function setWidth() { } self.setOption = function(key, value) { }; that.replaceElement = function(pos, element) { Ox.Log('Form', 'Ox.FormElementGroup replaceElement', pos, element) self.options.elements[pos].replaceWith(element.$element); self.options.elements[pos] = element; }; that.value = function() { return self.options.elements.map(function(element) { var ret = null; ['checked', 'selected', 'value'].forEach(function(v) { element[v] && (ret = element[v]()); }); return ret; }); }; return that; };