Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
39311e2e
Commit
39311e2e
authored
Feb 19, 2009
by
Richard Mansfield
Browse files
Pieforms support for multiple js file uploads from the same form
parent
07ac8f9d
Changes
2
Hide whitespace changes
Inline
Side-by-side
htdocs/lib/pieforms/pieform.php
View file @
39311e2e
...
...
@@ -691,6 +691,8 @@ class Pieform {/*{{{*/
'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 @@ EOF;
// 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()
...
...
htdocs/lib/pieforms/static/core/pieforms.js
View file @
39311e2e
...
...
@@ -149,8 +149,9 @@ function Pieform(data) {//{{{
}
// 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 @@ function Pieform(data) {//{{{
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
'
);
}
else
{
removeElementClass
(
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
);
}
// 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 @@ function Pieform(data) {//{{{
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 @@ function Pieform(data) {//{{{
});
insertSiblingNodesAfter
(
self
.
data
.
name
,
self
.
iframe
);
}
return
iframeName
;
}
//}}}
this
.
connectSubmitButtons
=
function
()
{
//{{{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment