[Pieforms-commit] SF.net SVN: pieforms:[302] pieforms-php5/trunk/src
Status: Alpha
Brought to you by:
oracleshinoda
|
From: <ora...@us...> - 2009-02-23 05:17:09
|
Revision: 302
http://pieforms.svn.sourceforge.net/pieforms/?rev=302&view=rev
Author: oracleshinoda
Date: 2009-02-23 05:17:03 +0000 (Mon, 23 Feb 2009)
Log Message:
-----------
Allow recreation of iframe for async submission every time a form is submitted (needed for multiple file uploads)
Modified Paths:
--------------
pieforms-php5/trunk/src/pieform.php
pieforms-php5/trunk/src/static/core/pieforms.js
Modified: pieforms-php5/trunk/src/pieform.php
===================================================================
--- pieforms-php5/trunk/src/pieform.php 2009-01-16 02:18:28 UTC (rev 301)
+++ pieforms-php5/trunk/src/pieform.php 2009-02-23 05:17:03 UTC (rev 302)
@@ -691,6 +691,8 @@
'jsErrorCallback' => $this->data['jserrorcallback'],
'globalJsErrorCallback' => $this->data['globaljserrorcallback'],
'postSubmitCallback' => $this->data['postsubmitcallback'],
+ 'newIframeOnSubmit' => $this->data['newiframeonsubmit'],
+ 'reloadFormOnReply' => $this->data['reloadformonreply'],
));
$result .= "<script type=\"text/javascript\">new Pieform($data);</script>\n";
}
@@ -1338,6 +1340,15 @@
// supported in less browsers. Most modern browsers should be fine)
'jsform' => false,
+ // Whether the form will target a new hidden iframe every time it's
+ // submitted.
+ 'newiframeonsubmit' => false,
+
+ // Whether the contents of the form should be reloaded on the page when
+ // a reply is received from the server. If false, error messages will
+ // not automatically be displayed inside the form.
+ 'reloadformonreply' => true,
+
// The URL where pieforms.js and other related pieforms javascript
// files can be accessed. Best specified as an absolute path in
// pieform_configure()
Modified: pieforms-php5/trunk/src/static/core/pieforms.js
===================================================================
--- pieforms-php5/trunk/src/static/core/pieforms.js 2009-01-16 02:18:28 UTC (rev 301)
+++ pieforms-php5/trunk/src/static/core/pieforms.js 2009-02-23 05:17:03 UTC (rev 302)
@@ -149,8 +149,9 @@
}
// Ensure the iframe exists and make sure the form targets it
- self.setupIframe();
- $(self.data.name).target = self.data.name + '_iframe';
+ // self.data.newIframes = true;
+ var iframeName = self.setupIframe();
+ $(self.data.name).target = iframeName;
appendChildNodes(self.data.name,
INPUT({
@@ -169,26 +170,28 @@
PieformManager.signal('onreply', self.data.name);
- var tmp = DIV();
- tmp.innerHTML = data.replaceHTML;
+ if (self.data.reloadFormOnReply) {
+ var tmp = DIV();
+ tmp.innerHTML = data.replaceHTML;
- // Work out whether the new form tag has the error class on it, for
- // updating the form in the document
- if (hasElementClass(tmp.childNodes[0], 'error')) {
- addElementClass(self.data.name, 'error');
+ // Work out whether the new form tag has the error class on it, for
+ // updating the form in the document
+ if (hasElementClass(tmp.childNodes[0], 'error')) {
+ addElementClass(self.data.name, 'error');
+ }
+ else {
+ removeElementClass(self.data.name, 'error');
+ }
+
+ // The first child node is the form tag. We replace the children of
+ // the current form tag with the new children. This prevents
+ // javascript references being lost
+ replaceChildNodes($(self.data.name), tmp.childNodes[0].childNodes);
+
+ self.connectSubmitButtons();
+ PieformManager.signal('onload', self.data.name);
}
- else {
- removeElementClass(self.data.name, 'error');
- }
- // The first child node is the form tag. We replace the children of
- // the current form tag with the new children. This prevents
- // javascript references being lost
- replaceChildNodes($(self.data.name), tmp.childNodes[0].childNodes);
-
- self.connectSubmitButtons();
- PieformManager.signal('onload', self.data.name);
-
if (data.returnCode == 0) {
// Call the defined success callback, if there is one
if (typeof(self.data.jsSuccessCallback) == 'string'
@@ -229,6 +232,13 @@
this.setupIframe = function() {//{{{
var iframeName = self.data.name + '_iframe';
+ if (self.data.newIframeOnSubmit) {
+ if (!self.data.nextIframe) {
+ self.data.nextIframe = 0;
+ }
+ iframeName += '_' + self.data.nextIframe;
+ self.data.nextIframe++;
+ }
if ($(iframeName)) {
self.iframe = $(iframeName);
}
@@ -240,6 +250,7 @@
});
insertSiblingNodesAfter(self.data.name, self.iframe);
}
+ return iframeName;
}//}}}
this.connectSubmitButtons = function() {//{{{
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|