summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/js
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Web/Javascripts/js')
-rw-r--r--framework/Web/Javascripts/js/ajax.js45
-rw-r--r--framework/Web/Javascripts/js/validator.js3
2 files changed, 40 insertions, 8 deletions
diff --git a/framework/Web/Javascripts/js/ajax.js b/framework/Web/Javascripts/js/ajax.js
index 5d929f77..ada940df 100644
--- a/framework/Web/Javascripts/js/ajax.js
+++ b/framework/Web/Javascripts/js/ajax.js
@@ -62,8 +62,8 @@ msg+=e.version+" "+e.time+"\n";return msg;}},encode:function(data)
return Prado.JSON.parse(data);else
return null;},dispatchPriorityRequest:function(callback)
{this.abortRequestInProgress();callback.request=new Ajax.Request(callback.url,callback.options);callback.timeout=setTimeout(function()
-{Prado.CallbackRequest.abortRequestInProgress();},callback.options.RequestTimeOut);this.requestInProgress=callback;},dispatchNormalRequest:function(callback)
-{new Ajax.Request(callback.url,callback.options);},abortRequestInProgress:function()
+{Prado.CallbackRequest.abortRequestInProgress();},callback.options.RequestTimeOut);this.requestInProgress=callback;return true;},dispatchNormalRequest:function(callback)
+{new Ajax.Request(callback.url,callback.options);return true;},abortRequestInProgress:function()
{inProgress=Prado.CallbackRequest.requestInProgress;if(inProgress)
{inProgress.request.transport.abort();clearTimeout(inProgress.timeout);Prado.CallbackRequest.requestInProgress=null;return true;}
return false;},updatePageState:function(request,transport)
@@ -88,10 +88,10 @@ Ajax.Responders.register(Prado.CallbackRequest.Exception);});Prado.CallbackReque
{return this.options['ValidationGroup'];},dispatch:function()
{Object.extend(this.options,{postBody:this._getPostData(),parameters:''});if(this.options.CausesValidation&&typeof(Prado.Validation)!="undefined")
{var form=this.options.Form||Prado.Validation.getForm();if(Prado.Validation.validate(form,this.options.ValidationGroup,this)==false)
-return;}
+return false;}
if(this.options.HasPriority)
-Prado.CallbackRequest.dispatchPriorityRequest(this);else
-Prado.CallbackRequest.dispatchNormalRequest(this);},_getPostData:function()
+return Prado.CallbackRequest.dispatchPriorityRequest(this);else
+return Prado.CallbackRequest.dispatchNormalRequest(this);},_getPostData:function()
{var data={};var callback=Prado.CallbackRequest;if(this.options.PostInputs!=false)
{callback.PostDataLoaders.each(function(name)
{$A(document.getElementsByName(name)).each(function(element)
@@ -212,7 +212,7 @@ this.onInit(options);},doCallback:function(event,options)
{request=new Prado.CallbackRequest(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()
{options=new Array(this.getToken(),"__TAutoComplete_onSuggest__");Prado.Callback(this.options.EventTarget,options,null,this.options);},onComplete:function(request,boundary)
-{result=Prado.Element.extractContent(request.responseText,boundary);if(typeof(result)=="string"&&result.length>0)
+{result=Prado.Element.extractContent(request.transport.responseText,boundary);if(typeof(result)=="string"&&result.length>0)
this.updateChoices(result);}});Prado.WebUI.TTimeTriggeredCallback=Base.extend({count:0,timeout:0,constructor:function(options)
{this.options=Object.extend({Interval:1,DecayRate:0},options||{})
this.onComplete=this.options.onComplete;Prado.WebUI.TTimeTriggeredCallback.register(this);},startTimer:function()
@@ -250,4 +250,35 @@ this.time=setTimeout(this.checkChanges.bind(this),parseInt(this.options.Interval
{request=new Prado.CallbackRequest(this.options.ID,this.options);param={'OldValue':oldValue,'NewValue':newValue};request.setParameter(param);request.dispatch();}},{timers:{},register:function(timer)
{this.timers[timer.options.ID]=timer;},stop:function(id)
{if(this.timers[id])
-this.timers[id].stopObserving();}}); \ No newline at end of file
+this.timers[id].stopObserving();}});Prado.WebUI.TInPlaceTextBox=Base.extend({isSaving:false,isEditing:false,editField:null,constructor:function(options)
+{this.options=Object.extend({LoadTextFromSource:false,TextMode:'SingleLine'},options||{});this.element=$(this.options.ID);this.initializeListeners();},initializeListeners:function()
+{this.onclickListener=this.enterEditMode.bindAsEventListener(this);Event.observe(this.element,'click',this.onclickListener);if(this.options.ExternalControl)
+Event.observe($(this.options.ExternalControl),'click',this.onclickListener);},enterEditMode:function(evt)
+{if(this.isSaving)return;if(this.isEditing)return;this.isEditing=true;this.onEnterEditMode();this.createEditorInput();this.showTextBox();this.editField.disabled=false;if(this.options.LoadTextOnEdit)
+this.loadExternalText();Prado.Element.focus(this.editField);if(evt)
+Event.stop(evt);return false;},showTextBox:function()
+{Element.hide(this.element);Element.show(this.editField);},showLabel:function()
+{Element.show(this.element);Element.hide(this.editField);},createEditorInput:function()
+{if(this.editField==null)
+this.createTextBox();this.editField.value=this.getText();},loadExternalText:function()
+{this.editField.disabled=true;this.onLoadingText();options=new Array('__InlineEditor_loadExternalText__',this.getText());request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setCausesValidation(false);request.setParameter(options);request.options.onSuccess=this.onloadExternalTextSuccess.bind(this);request.options.onFailure=this.onloadExternalTextFailure.bind(this);request.dispatch();},createTextBox:function()
+{cssClass=this.options.TextBoxCssClass||'editor_field';inputName=this.options.EventTarget;options={'className':cssClass,name:inputName,id:this.options.TextBoxID};this.editField=this.options.TextMode=='SingleLine'?INPUT(options):TEXTAREA(options);this.editField.style.display="none";this.element.parentNode.insertBefore(this.editField,this.element)
+if(this.options.TextMode=='SingleLine')
+{Event.observe(this.editField,"keydown",function(e)
+{if(Event.keyCode(e)==Event.KEY_RETURN)
+{var target=Event.element(e);if(target)
+{Event.fireEvent(target,"blur");Event.stop(e);}}});}
+Event.observe(this.editField,"blur",this.onTextBoxBlur.bind(this));},getText:function()
+{return this.element.innerHTML;},onEnterEditMode:function()
+{if(typeof(this.options.onEnterEditMode)=="function")
+this.options.onEnterEditMode(this,null);},onTextBoxBlur:function(e)
+{text=this.element.innerHTML;if(text!=this.editField.value)
+this.onTextChanged(text);else
+{this.isEditing=false;this.showLabel();}},onTextChanged:function(text)
+{request=new Prado.CallbackRequest(this.options.EventTarget,this.options);request.setParameter(text);request.options.onSuccess=this.onTextChangedSuccess.bind(this);request.options.onFailure=this.onTextChangedFailure.bind(this);if(request.dispatch())
+{this.isSaving=true;this.editField.disabled=true;}},onLoadingText:function()
+{},onloadExternalTextSuccess:function(request,parameter)
+{this.isEditing=true;this.editField.disabled=false;this.editField.value=this.getText();Prado.Element.focus(this.editField);},onloadExternalTextFailure:function(request,parameter)
+{this.isSaving=false;this.isEditing=false;this.showLabel();},onTextChangedSuccess:function(sender,parameter)
+{this.isSaving=false;this.isEditing=false;this.showLabel();this.element.innerHTML=parameter==null?this.editField.value:parameter;},onTextChangedFailure:function(sender,parameter)
+{this.editField.disabled=false;this.isSaving=false;this.isEditing=false;}}); \ No newline at end of file
diff --git a/framework/Web/Javascripts/js/validator.js b/framework/Web/Javascripts/js/validator.js
index 711c996e..02380663 100644
--- a/framework/Web/Javascripts/js/validator.js
+++ b/framework/Web/Javascripts/js/validator.js
@@ -95,7 +95,8 @@ Prado.Element.focus(this.options.FocusElementID);this.visible=true;},updateContr
control.removeClassName(CssClass);else
control.addClassName(CssClass);}},hide:function()
{this.isValid=true;this.updateControl();this.visible=false;},validate:function(invoker)
-{if(typeof(this.options.OnValidate)=="function")
+{if(!this.control)
+this.control=$(this.options.ControlToValidate);if(typeof(this.options.OnValidate)=="function")
this.options.OnValidate(this,invoker);if(this.enabled)
this.isValid=this.evaluateIsValid();else
this.isValid=true;if(this.isValid)