summaryrefslogtreecommitdiff
path: root/framework/Web/Javascripts/prado
diff options
context:
space:
mode:
authorwei <>2006-08-29 12:06:35 +0000
committerwei <>2006-08-29 12:06:35 +0000
commitf0a6fad58f8eae14554443081ffb166aaf71762a (patch)
treea1a234da831f11c190a0cef98d01c6f0dacdce1c /framework/Web/Javascripts/prado
parentc1937cccd0985e86e247287faa9ac60870feecd7 (diff)
fixed autocomplete problem and add TInPlcaeTextbox
Diffstat (limited to 'framework/Web/Javascripts/prado')
-rw-r--r--framework/Web/Javascripts/prado/activecontrols3.js2
-rw-r--r--framework/Web/Javascripts/prado/ajax3.js8
-rw-r--r--framework/Web/Javascripts/prado/inlineeditor.js208
-rw-r--r--framework/Web/Javascripts/prado/validation3.js16
4 files changed, 224 insertions, 10 deletions
diff --git a/framework/Web/Javascripts/prado/activecontrols3.js b/framework/Web/Javascripts/prado/activecontrols3.js
index bd8aa6a5..e5be1d49 100644
--- a/framework/Web/Javascripts/prado/activecontrols3.js
+++ b/framework/Web/Javascripts/prado/activecontrols3.js
@@ -115,7 +115,7 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete,
onComplete : function(request, boundary)
{
- result = Prado.Element.extractContent(request.responseText, boundary);
+ result = Prado.Element.extractContent(request.transport.responseText, boundary);
if(typeof(result) == "string" && result.length > 0)
this.updateChoices(result);
}
diff --git a/framework/Web/Javascripts/prado/ajax3.js b/framework/Web/Javascripts/prado/ajax3.js
index c5683139..a11fe1aa 100644
--- a/framework/Web/Javascripts/prado/ajax3.js
+++ b/framework/Web/Javascripts/prado/ajax3.js
@@ -262,6 +262,7 @@ Object.extend(Prado.CallbackRequest,
},callback.options.RequestTimeOut);
this.requestInProgress = callback;
+ return true;
//Logger.info("dispatched "+this.requestInProgress)
},
@@ -272,6 +273,7 @@ Object.extend(Prado.CallbackRequest,
{
// Logger.info("dispatching normal request");
new Ajax.Request(callback.url, callback.options);
+ return true;
},
/**
@@ -460,13 +462,13 @@ Prado.CallbackRequest.prototype =
{
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);
+ return Prado.CallbackRequest.dispatchPriorityRequest(this);
else
- Prado.CallbackRequest.dispatchNormalRequest(this);
+ return Prado.CallbackRequest.dispatchNormalRequest(this);
},
/**
diff --git a/framework/Web/Javascripts/prado/inlineeditor.js b/framework/Web/Javascripts/prado/inlineeditor.js
new file mode 100644
index 00000000..4eb33d5c
--- /dev/null
+++ b/framework/Web/Javascripts/prado/inlineeditor.js
@@ -0,0 +1,208 @@
+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();
+ },
+
+ /**
+ * Initialize the listeners.
+ */
+ 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);
+ },
+
+ /**
+ * Changes the panel to an editable input.
+ * @param {Event} evt event source
+ */
+ 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);
+ },
+
+ /**
+ * Create the edit input field.
+ */
+ 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();
+ },
+
+ /**
+ * Create a new input textbox or textarea
+ */
+ 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)
+
+ //handle return key within single line textbox
+ 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));
+ },
+
+ /**
+ * @return {String} panel inner html text.
+ */
+ getText: function()
+ {
+ return this.element.innerHTML;
+ },
+
+ /**
+ * Edit mode entered, calls optional event handlers.
+ */
+ 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();
+ }
+ },
+
+ /**
+ * When the text input value has changed.
+ * @param {String} original text
+ */
+ 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;
+ }
+ },
+
+ /**
+ * When loading external text.
+ */
+ onLoadingText : function()
+ {
+ //Logger.info("on loading text");
+ },
+
+ 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();
+ },
+
+ /**
+ * Text change successfully.
+ * @param {Object} sender
+ * @param {Object} parameter
+ */
+ 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/prado/validation3.js b/framework/Web/Javascripts/prado/validation3.js
index 7df6efeb..86659323 100644
--- a/framework/Web/Javascripts/prado/validation3.js
+++ b/framework/Web/Javascripts/prado/validation3.js
@@ -97,7 +97,7 @@ Object.extend(Prado.Validation,
var keys = $H(this.managers).keys();
return keys[0];
},
-
+
/**
* Check if the validators are valid for a particular form (and group).
* The validators states will not be changed.
@@ -656,6 +656,10 @@ Prado.WebUI.TBaseValidator.prototype =
*/
validate : function(invoker)
{
+ //try to find the control.
+ if(!this.control)
+ this.control = $(this.options.ControlToValidate);
+
if(typeof(this.options.OnValidate) == "function")
this.options.OnValidate(this, invoker);
@@ -765,9 +769,9 @@ Prado.WebUI.TBaseValidator.prototype =
return value;
},
- /**
+ /**
* The ControlType property comes from TBaseValidator::getClientControlClass()
- * Be sure to update the TBaseValidator::$_clientClass if new cases are added.
+ * Be sure to update the TBaseValidator::$_clientClass if new cases are added.
* @return mixed control value to validate
*/
getValidationValue : function(control)
@@ -780,7 +784,7 @@ Prado.WebUI.TBaseValidator.prototype =
if(control.type == "text")
{
value = this.trim($F(control));
-
+
if(this.options.DateFormat)
{
date = value.toDate(this.options.DateFormat);
@@ -1125,7 +1129,7 @@ Prado.WebUI.TRangeValidator = Class.extend(Prado.WebUI.TBaseValidator,
return true;
if(typeof(this.options.DataType) == "undefined")
this.options.DataType = "String";
-
+
if(this.options.DataType != "StringLength")
{
var min = this.convert(this.options.DataType, this.options.MinValue || null);
@@ -1138,7 +1142,7 @@ Prado.WebUI.TRangeValidator = Class.extend(Prado.WebUI.TBaseValidator,
var max = this.options.MaxValue || Number.POSITIVE_INFINITY;
value = value.length;
}
-
+
if(value == null)
return false;