diff options
author | xue <> | 2005-12-05 01:00:16 +0000 |
---|---|---|
committer | xue <> | 2005-12-05 01:00:16 +0000 |
commit | ccf76e430b7703db028966a845a966f50956f490 (patch) | |
tree | 9762b746f8b7d432dbe5e5cb8f38f90007e0e1b5 /framework/Web/Javascripts/base/postback.js | |
parent | 418baf36d477bcbdd6fb4eaf4037ea6a2d93f21c (diff) |
Diffstat (limited to 'framework/Web/Javascripts/base/postback.js')
-rw-r--r-- | framework/Web/Javascripts/base/postback.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/framework/Web/Javascripts/base/postback.js b/framework/Web/Javascripts/base/postback.js new file mode 100644 index 00000000..8b2d522e --- /dev/null +++ b/framework/Web/Javascripts/base/postback.js @@ -0,0 +1,72 @@ +
+Prado.PostBack = Class.create();
+
+Prado.PostBack.Options = Class.create();
+
+Prado.PostBack.Options.prototype =
+{
+ initialize : function(performValidation, validationGroup, actionUrl, trackFocus, clientSubmit)
+ {
+ this.performValidation = performValidation;
+ this.validationGroup = validationGroup;
+ this.actionUrl = actionUrl;
+ this.trackFocus = trackFocus;
+ this.clientSubmit = clientSubmit;
+ }
+}
+
+Prado.PostBack.perform = function(formID, eventTarget, eventParameter, options)
+{
+ var theForm = document.getElementById ? document.getElementById(formID) : document.forms[formID];
+ var canSubmit = true;
+ if ((typeof(options) != 'undefined') || options == null)
+ {
+ if (options.performValidation)
+ {
+ canSubmit = Prado.Validation.validate(options.validationGroup);
+ }
+ if (canSubmit)
+ {
+ if ((typeof(options.actionUrl) != 'undefined') && (options.actionUrl != null) && (options.actionUrl.length > 0))
+ {
+ theForm.action = options.actionUrl;
+ }
+ if (options.trackFocus)
+ {
+ var lastFocus = theForm.elements['PRADO_LASTFOCUS'];
+ if ((typeof(lastFocus) != 'undefined') && (lastFocus != null))
+ {
+ var active = document.activeElement;
+ if (typeof(active) == 'undefined')
+ {
+ lastFocus.value = eventTarget;
+ }
+ else
+ {
+ if ((active != null) && (typeof(active.id) != 'undefined'))
+ {
+ if (active.id.length > 0)
+ {
+ lastFocus.value = active.id;
+ }
+ else if (typeof(active.name) != 'undefined')
+ {
+ lastFocus.value = active.name;
+ }
+ }
+ }
+ }
+ }
+ if (!options.clientSubmit)
+ {
+ canSubmit = false;
+ }
+ }
+ }
+ if (canSubmit && (!theForm.onsubmit || theForm.onsubmit()))
+ {
+ theForm.PRADO_POSTBACK_TARGET.value = eventTarget;
+ theForm.PRADO_POSTBACK_PARAMETER.value = eventParameter;
+ theForm.submit();
+ }
+}
\ No newline at end of file |