RadioButtonGroup = Class.create({ initialize: function(element) { element = $(element); this.element = element; element.JSControl = this; this.id = element.readAttribute("id"); this.value = element.readAttribute("value"); this.children = []; }, AddChild: function(obj) { this.children.push(obj); }, ID: function() { return this.id; }, Choose: function(data) { this.value = data; new AEvent("CHANGE", {}, this); }, Value: function(){ return URLRestore( this.value + "&" ); }, SetSerializedValue: function(data){ this.SetValue( URLRestore(data + "&") ); }, SetValue: function(data){ if (data instanceof Optional) data = data.Value(); data = URLSerialize(data); for (var i = 0; i < this.children.length; ++i) { if (this.children[i].value == data) break; } this.value=data; if (i >= this.children.length) i = 0; this.children[i].element.checked = true; }, SetTabOrder: function(nTabBase){ return nTabBase; } }); RadioButton = Class.create({ initialize: function(element){ element = $(element); this.element = element; element.JSControl = this; this.id = element.readAttribute("id"); this.value = URLSerialize( URLRestore(element.readAttribute("value") + "&") ); this.group = $(element.readAttribute("name")).JSControl; this.visibility=element.readAttribute("visibility"); if(this.visibility=="vo" || this.visibility=="ro" || this.visibility=="link") { this.element.writeAttribute("disabled", "disabled"); } Event.observe(this.element, "change", this.OnChange.bindAsEventListener(this)); var wnd = AControl.GetParentWindow(this.element); wnd.Subscribe("REGISTERCHILDCONTROL", this.RegisterChildControl, this); this.group.AddChild(this, this.value); }, OnChange: function(){ if (this.element.checked) this.group.Choose(this.value); }, Click: function(evt) { this.element.checked = true; this.OnChange(); }, RegisterChildControl: function(evt) { var p = evt.Data(); if (p.controlId != this.id) return; this.element.observe("focus", function(evt) { evt.target.blur(); evt.stop(); return false; }); this.element.observe("mousedown", function(evt) { evt.stop(); return false; }); p.subscribeOnClick(this.Click.bind(this)); }, ID: function(){ return this.id; }, Value: function(){ return (this.element.checked ? this.value : null); }, SetValue: function(data){ }, SetTabOrder: function(nTabBase){ this.element.tabIndex = nTabBase; return ++nTabBase; } });