From 9d2b8de5699f51ca253bac7d188ac109b3aa84b2 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 30 Mar 2007 13:09:22 +0000 Subject: Fixed #557. --- framework/Web/Javascripts/js/compressed/ajax.js | 13 +++++--- framework/Web/Javascripts/js/debug/ajax.js | 35 +++++++++++++++++++--- .../prado/activecontrols/activecontrols3.js | 35 +++++++++++++++++++--- 3 files changed, 71 insertions(+), 12 deletions(-) (limited to 'framework') diff --git a/framework/Web/Javascripts/js/compressed/ajax.js b/framework/Web/Javascripts/js/compressed/ajax.js index c1ce7504..cc967514 100644 --- a/framework/Web/Javascripts/js/compressed/ajax.js +++ b/framework/Web/Javascripts/js/compressed/ajax.js @@ -224,14 +224,19 @@ Event.stop(event);}});Prado.WebUI.TActiveRadioButton=Class.extend(Prado.WebUI.TA Event.observe(this.element,"keydown",this.handleReturnKey.bind(this));if(this.options['AutoPostBack']==true) Event.observe(this.element,"change",this.doCallback.bindEvent(this,options));},doCallback:function(event,options) {var request=new Prado.CallbackRequest(options.EventTarget,options);request.dispatch();Event.stop(event);}});Prado.WebUI.TAutoComplete=Class.extend(Autocompleter.Base,Prado.WebUI.TActiveTextBox.prototype);Prado.WebUI.TAutoComplete=Class.extend(Prado.WebUI.TAutoComplete,{initialize:function(options) -{this.options=options;this.baseInitialize(options.ID,options.ResultPanel,options);Object.extend(this.options,{onSuccess:this.onComplete.bind(this)});if(options.AutoPostBack) +{this.options=options;this.hasResults=false;this.baseInitialize(options.ID,options.ResultPanel,options);Object.extend(this.options,{onSuccess:this.onComplete.bind(this)});if(options.AutoPostBack) this.onInit(options);},doCallback:function(event,options) {if(!this.active) {var request=new Prado.CallbackRequest(this.options.EventTarget,options);request.dispatch();Event.stop(event);}},onClick:function(event) {var element=Event.findElement(event,'LI');this.index=element.autocompleteIndex;this.selectEntry();this.hide();Event.fireEvent(this.element,"change");},getUpdatedChoices:function() -{var options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},onComplete:function(request,boundary) -{var result=Prado.Element.extractContent(request.transport.responseText,boundary);if(typeof(result)=="string"&&result.length>0) -this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({constructor:function(options) +{var options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},selectEntry:function() +{if(this.hasResults) +{this.active=false;this.updateElement(this.getCurrentEntry());}},onComplete:function(request,boundary) +{var result=Prado.Element.extractContent(request.transport.responseText,boundary);if(typeof(result)=="string") +{if(result.length>0) +{this.hasResults=true;this.updateChoices(result);} +else +{this.active=false;this.hasResults=false;this.hide();}}},});Prado.WebUI.TTimeTriggeredCallback=Base.extend({constructor:function(options) {this.options=Object.extend({Interval:1},options||{});Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function() {setTimeout(this.onTimerEvent.bind(this),100);if(typeof(this.timer)=='undefined'||this.timer==null) this.timer=setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000);},stopTimer:function() diff --git a/framework/Web/Javascripts/js/debug/ajax.js b/framework/Web/Javascripts/js/debug/ajax.js index 4b20a8de..1016f435 100644 --- a/framework/Web/Javascripts/js/debug/ajax.js +++ b/framework/Web/Javascripts/js/debug/ajax.js @@ -1978,6 +1978,7 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, initialize : function(options) { this.options = options; + this.hasResults = false; this.baseInitialize(options.ID, options.ResultPanel, options); Object.extend(this.options, { @@ -2014,12 +2015,38 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, Prado.Callback(this.options.EventTarget, options, null, this.options); }, - onComplete : function(request, boundary) + /** + * Overrides parent implements, don't update if no results. + */ + selectEntry: function() + { + if(this.hasResults) + { + this.active = false; + this.updateElement(this.getCurrentEntry()); + } + }, + + onComplete : function(request, boundary) { var result = Prado.Element.extractContent(request.transport.responseText, boundary); - if(typeof(result) == "string" && result.length > 0) - this.updateChoices(result); - } + if(typeof(result) == "string") + { + if(result.length > 0) + { + this.hasResults = true; + this.updateChoices(result); + } + else + { + this.active = false; + this.hasResults = false; + this.hide(); + } + } + }, + + }); /** diff --git a/framework/Web/Javascripts/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols/activecontrols3.js index bb61d8ea..86521ca3 100644 --- a/framework/Web/Javascripts/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/prado/activecontrols/activecontrols3.js @@ -98,6 +98,7 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, initialize : function(options) { this.options = options; + this.hasResults = false; this.baseInitialize(options.ID, options.ResultPanel, options); Object.extend(this.options, { @@ -134,12 +135,38 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, Prado.Callback(this.options.EventTarget, options, null, this.options); }, - onComplete : function(request, boundary) + /** + * Overrides parent implements, don't update if no results. + */ + selectEntry: function() + { + if(this.hasResults) + { + this.active = false; + this.updateElement(this.getCurrentEntry()); + } + }, + + onComplete : function(request, boundary) { var result = Prado.Element.extractContent(request.transport.responseText, boundary); - if(typeof(result) == "string" && result.length > 0) - this.updateChoices(result); - } + if(typeof(result) == "string") + { + if(result.length > 0) + { + this.hasResults = true; + this.updateChoices(result); + } + else + { + this.active = false; + this.hasResults = false; + this.hide(); + } + } + }, + + }); /** -- cgit v1.2.3