From 7949f7fe746dbbe3eeefbc123bbb2c551b091733 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Apr 2006 05:14:34 +0000 Subject: Fixed #93 and #121 --- framework/Web/Javascripts/js/colorpicker.js | 2 +- framework/Web/Javascripts/js/prado.js | 293 ++++++++++++++------------ framework/Web/Javascripts/js/validator.js | 2 +- framework/Web/Javascripts/prado/controls.js | 48 ++++- framework/Web/Javascripts/prado/form.js | 13 +- framework/Web/Javascripts/prado/validation.js | 3 +- framework/Web/UI/WebControls/TImageButton.php | 1 + 7 files changed, 218 insertions(+), 144 deletions(-) (limited to 'framework') diff --git a/framework/Web/Javascripts/js/colorpicker.js b/framework/Web/Javascripts/js/colorpicker.js index 5668be98..3dde7692 100644 --- a/framework/Web/Javascripts/js/colorpicker.js +++ b/framework/Web/Javascripts/js/colorpicker.js @@ -320,7 +320,7 @@ this.inputs=_65; var _67=Prado.WebUI.TColorPicker.UIImages; this.inputs["currentColor"]=SPAN({className:"currentColor"}); this.inputs["oldColor"]=SPAN({className:"oldColor"}); -var _68=TABLE({className:"inputs"},TBODY(null,TR(null,TD({className:"currentcolor",colSpan:2},this.inputs["currentColor"],this.inputs["oldColor"])),TR(null,TD(null,"H:"),TD(null,this.inputs["H"],"\u63b3")),TR(null,TD(null,"S:"),TD(null,this.inputs["S"],"%")),TR(null,TD(null,"V:"),TD(null,this.inputs["V"],"%")),TR(null,TD({className:"gap"},"R:"),TD({className:"gap"},this.inputs["R"])),TR(null,TD(null,"G:"),TD(null,this.inputs["G"])),TR(null,TD(null,"B:"),TD(null,this.inputs["B"])),TR(null,TD({className:"gap"},"#"),TD({className:"gap"},this.inputs["HEX"])))); +var _68=TABLE({className:"inputs"},TBODY(null,TR(null,TD({className:"currentcolor",colSpan:2},this.inputs["currentColor"],this.inputs["oldColor"])),TR(null,TD(null,"H:"),TD(null,this.inputs["H"],"\xc2\xb0")),TR(null,TD(null,"S:"),TD(null,this.inputs["S"],"%")),TR(null,TD(null,"V:"),TD(null,this.inputs["V"],"%")),TR(null,TD({className:"gap"},"R:"),TD({className:"gap"},this.inputs["R"])),TR(null,TD(null,"G:"),TD(null,this.inputs["G"])),TR(null,TD(null,"B:"),TD(null,this.inputs["B"])),TR(null,TD({className:"gap"},"#"),TD({className:"gap"},this.inputs["HEX"])))); var _69={selector:SPAN({className:"selector"}),background:SPAN({className:"colorpanel"}),slider:SPAN({className:"slider"}),hue:SPAN({className:"strip"})}; if(Prado.Browser().ie){ var _70="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"; diff --git a/framework/Web/Javascripts/js/prado.js b/framework/Web/Javascripts/js/prado.js index d142a070..a60372e8 100644 --- a/framework/Web/Javascripts/js/prado.js +++ b/framework/Web/Javascripts/js/prado.js @@ -1677,12 +1677,13 @@ Prado.PostBack=function(_379,_380){ var form=$(_380["FormID"]); var _381=true; if(_380["CausesValidation"]&&Prado.Validation){ +var _382=true; if(_380["ValidationGroup"]){ -Prado.Validation.SetActiveGroup(Event.element(_379),_380["ValidationGroup"]); +_382=Prado.Validation.ValidateValidationGroup(_380["ValidationGroup"]); }else{ -Prado.Validation.SetActiveGroup(null,null); +_382=Prado.Validation.ValidateNonGroup(form); } -if(Prado.Validation.IsValid(form)==false){ +if(!_382){ if(_380["StopEvent"]){ Event.stop(_379); } @@ -1693,13 +1694,13 @@ if(_380["PostBackUrl"]&&_380["PostBackUrl"].length>0){ form.action=_380["PostBackUrl"]; } if(_380["TrackFocus"]){ -var _382=$("PRADO_LASTFOCUS"); -if(_382){ -var _383=document.activeElement; +var _383=$("PRADO_LASTFOCUS"); if(_383){ -_382.value=_383.id; +var _384=document.activeElement; +if(_384){ +_383.value=_384.id; }else{ -_382.value=_380["EventTarget"]; +_383.value=_380["EventTarget"]; } } } @@ -1710,24 +1711,24 @@ if(_380["StopEvent"]){ Event.stop(_379); } }; -Prado.Element={setValue:function(_384,_385){ -var el=$(_384); +Prado.Element={setValue:function(_385,_386){ +var el=$(_385); if(el&&typeof (el.value)!="undefined"){ -el.value=_385; +el.value=_386; } -},select:function(_387,_388,_389){ -var el=$(_387); -var _390=_387.indexOf("[]")>-1; -if(!el&&!_390){ +},select:function(_388,_389,_390){ +var el=$(_388); +var _391=_388.indexOf("[]")>-1; +if(!el&&!_391){ return; } -_388=_390?"check"+_388:el.tagName.toLowerCase()+_388; -var _391=Prado.Element.Selection; -if(isFunction(_391[_388])){ -_391[_388](_390?_387:el,_389); +_389=_391?"check"+_389:el.tagName.toLowerCase()+_389; +var _392=Prado.Element.Selection; +if(isFunction(_392[_389])){ +_392[_389](_391?_388:el,_390); } -},click:function(_392){ -var el=$(_392); +},click:function(_393){ +var el=$(_393); if(!el){ return; } @@ -1743,25 +1744,25 @@ el.onclick(); } } } -},setAttribute:function(_394,_395,_396){ -var el=$(_394); -if(_395=="disabled"&&_396==false){ -el.removeAttribute(_395); +},setAttribute:function(_395,_396,_397){ +var el=$(_395); +if(_396=="disabled"&&_397==false){ +el.removeAttribute(_396); }else{ -el.setAttribute(_395,_396); +el.setAttribute(_396,_397); } -},setOptions:function(_397,_398){ -var el=$(_397); +},setOptions:function(_398,_399){ +var el=$(_398); if(el&&el.tagName.toLowerCase()=="select"){ while(el.length>0){ el.remove(0); } -for(var i=0;i<_398.length;i++){ -el.options[el.options.length]=new Option(_398[i][0],_398[i][1]); +for(var i=0;i<_399.length;i++){ +el.options[el.options.length]=new Option(_399[i][0],_399[i][1]); } } -},focus:function(_399){ -var obj=$(_399); +},focus:function(_400){ +var obj=$(_400); if(isObject(obj)&&isdef(obj.focus)){ setTimeout(function(){ obj.focus(); @@ -1769,22 +1770,22 @@ obj.focus(); } return false; }}; -Prado.Element.Selection={inputValue:function(el,_401){ +Prado.Element.Selection={inputValue:function(el,_402){ switch(el.type.toLowerCase()){ case "checkbox": case "radio": -return el.checked=_401; +return el.checked=_402; } -},selectValue:function(el,_402){ -$A(el.options).each(function(_403){ -_403.selected=_403.value==_402; +},selectValue:function(el,_403){ +$A(el.options).each(function(_404){ +_404.selected=_404.value==_403; }); -},selectIndex:function(el,_404){ +},selectIndex:function(el,_405){ if(el.type=="select-one"){ -el.selectedIndex=_404; +el.selectedIndex=_405; }else{ for(var i=0;i-1?this.radios[_448].value:this.options.caption; +this.setCaption(_456); +},setCaption:function(_457){ +this.caption.innerHTML=_457>-1?this.radios[_457].value:this.options.caption; }}; diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js index e1d0806a..b5321743 100644 --- a/framework/Web/Javascripts/js/validator.js +++ b/framework/Web/Javascripts/js/validator.js @@ -144,7 +144,7 @@ var _42=Prado.Validation.validators; for(var i=0;i<_42.length;i++){ _42[i].enabled=!_42[i].control||undef(_42[i].control.form)||_42[i].control.form==_40; _42[i].visible=Prado.Validation.IsGroupValidation?_42[i].inActiveGroup():true; -if(Prado.Validation.HasTargetGroup){ +if(Prado.Validation.HasTargetGroup||_42[i].group){ if(_42[i].group!=Prado.Validation.CurrentTargetGroup){ _42[i].enabled=false; } diff --git a/framework/Web/Javascripts/prado/controls.js b/framework/Web/Javascripts/prado/controls.js index 1d274fd8..0f736f91 100644 --- a/framework/Web/Javascripts/prado/controls.js +++ b/framework/Web/Javascripts/prado/controls.js @@ -69,11 +69,57 @@ Prado.WebUI.ClickableComponent = Prado.WebUI.createPostBackComponent( }); Prado.WebUI.TLinkButton = Prado.WebUI.ClickableComponent; -Prado.WebUI.TImageButton = Prado.WebUI.ClickableComponent; Prado.WebUI.TCheckBox = Prado.WebUI.ClickableComponent; Prado.WebUI.TBulletedList = Prado.WebUI.ClickableComponent; Prado.WebUI.TImageMap = Prado.WebUI.ClickableComponent; +/** + * TImageButton client-side behaviour. With validation, Firefox needs + * to capture the x,y point of the clicked image in hidden form fields. + */ +Prado.WebUI.TImageButton = Class.create(); +Object.extend(Prado.WebUI.TImageButton.prototype,Prado.WebUI.ClickableComponent.prototype); +Object.extend(Prado.WebUI.TImageButton.prototype, +{ + /** + * Only add the hidden inputs once. + */ + hasXYInput : false, + + /** + * Override parent onPostBack function, tried to add hidden forms + * inputs to capture x,y clicked point. + */ + onPostBack : function(event, options) + { + if(!this.hasXYInput) + { + this.addXYInput(event,options); + this.hasXYInput = true; + } + Prado.PostBack(event, options); + }, + + /** + * Add hidden inputs to capture the x,y point clicked on the image. + * @param event DOM click event. + * @param array image button options. + */ + addXYInput : function(event,options) + { + var imagePos = Position.cumulativeOffset(this.element); + var clickedPos = [event.clientX, event.clientY]; + var x = clickedPos[0]-imagePos[0]+1; + var y = clickedPos[1]-imagePos[1]+1; + var id = options['EventTarget']; + var x_input = INPUT({type:'hidden',name:id+'_x',value:x}); + var y_input = INPUT({type:'hidden',name:id+'_y',value:y}); + this.element.parentNode.appendChild(x_input); + this.element.parentNode.appendChild(y_input); + } +}); + + /** * Radio button, only initialize if not already checked. */ diff --git a/framework/Web/Javascripts/prado/form.js b/framework/Web/Javascripts/prado/form.js index 059aab5f..d2286b23 100644 --- a/framework/Web/Javascripts/prado/form.js +++ b/framework/Web/Javascripts/prado/form.js @@ -104,11 +104,18 @@ Prado.PostBack = function(event,options) var canSubmit = true; if(options['CausesValidation'] && Prado.Validation) { + var valid = true; if(options['ValidationGroup']) - Prado.Validation.SetActiveGroup(Event.element(event), options['ValidationGroup']); + { + valid = Prado.Validation.ValidateValidationGroup(options['ValidationGroup']); + // Prado.Validation.SetActiveGroup(Event.element(event), options['ValidationGroup']); + } else - Prado.Validation.SetActiveGroup(null,null); - if(Prado.Validation.IsValid(form) == false) + { + valid = Prado.Validation.ValidateNonGroup(form); + } + + if(!valid) { if(options['StopEvent']) Event.stop(event); return; diff --git a/framework/Web/Javascripts/prado/validation.js b/framework/Web/Javascripts/prado/validation.js index e7e45b2c..ba68becc 100644 --- a/framework/Web/Javascripts/prado/validation.js +++ b/framework/Web/Javascripts/prado/validation.js @@ -301,7 +301,7 @@ Prado.Validation.IsValid = function(form) //when group validation, only validators in the active group are visible. validators[i].visible = Prado.Validation.IsGroupValidation ? validators[i].inActiveGroup() : true; - if(Prado.Validation.HasTargetGroup) + if(Prado.Validation.HasTargetGroup || validators[i].group) { if(validators[i].group != Prado.Validation.CurrentTargetGroup) validators[i].enabled = false; @@ -739,6 +739,7 @@ Prado.Validation.ValidateValidationGroup= function(groupId) return Prado.Validation.IsValid(target.form); } } + return true; }; diff --git a/framework/Web/UI/WebControls/TImageButton.php b/framework/Web/UI/WebControls/TImageButton.php index e5e5f3b9..655b1df0 100644 --- a/framework/Web/UI/WebControls/TImageButton.php +++ b/framework/Web/UI/WebControls/TImageButton.php @@ -124,6 +124,7 @@ class TImageButton extends TImage implements IPostBackDataHandler, IPostBackEven $options['ID'] = $this->getClientID(); $options['CausesValidation'] = $this->getCausesValidation(); $options['ValidationGroup'] = $this->getValidationGroup(); + $options['EventTarget'] = $this->getUniqueID(); return $options; } -- cgit v1.2.3