Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
morpheus.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Daria Zenkova
morpheus.js
Commits
baa26b67
Commit
baa26b67
authored
Apr 24, 2016
by
jgould
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multiple file input
parent
f5b5bfaf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
+26
-11
src/ui/form_builder.js
src/ui/form_builder.js
+26
-11
No files found.
src/ui/form_builder.js
View file @
baa26b67
...
...
@@ -47,6 +47,7 @@ morpheus.FormBuilder = function(options) {
}).
on
(
'
drop
'
,
function
(
e
)
{
var
node
=
$
(
e
.
originalEvent
.
srcElement
).
parent
().
parent
().
prev
();
if
(
node
.
is
(
'
select
'
)
&&
node
.
hasClass
(
'
file-input
'
))
{
var
isMultiple
=
node
.
data
(
'
multiple
'
);
$
(
e
.
originalEvent
.
srcElement
).
parent
().
css
(
'
border
'
,
''
);
var
name
=
node
.
attr
(
'
name
'
);
name
=
name
.
substring
(
0
,
name
.
length
-
'
_picker
'
.
length
);
...
...
@@ -55,7 +56,7 @@ morpheus.FormBuilder = function(options) {
e
.
preventDefault
();
e
.
stopPropagation
();
var
files
=
e
.
originalEvent
.
dataTransfer
.
files
;
that
.
setValue
(
name
,
files
[
0
]);
that
.
setValue
(
name
,
isMultiple
?
files
:
files
[
0
]);
that
.
trigger
(
'
change
'
,
{
name
:
name
,
value
:
files
[
0
]
...
...
@@ -539,9 +540,13 @@ morpheus.FormBuilder.prototype = {
}
else
if
(
'
custom
'
===
type
)
{
html
.
push
(
value
);
}
else
if
(
'
file
'
===
type
)
{
var
isMultiple
=
field
.
multiple
;
html
.
push
(
'
<select type="file" title="
'
+
(
field
.
placeholder
||
'
Choose a file...
'
)
.
push
(
'
<select data-multiple="
'
+
isMultiple
+
'
" type="file" title="
'
+
(
field
.
placeholder
||
(
isMultiple
?
'
Choose one or more files...
'
:
'
Choose a file...
'
))
+
'
" name="
'
+
name
+
'
_picker" data-width="35%" class="file-input selectpicker form-control">
'
);
...
...
@@ -586,16 +591,21 @@ morpheus.FormBuilder.prototype = {
if
(
field
.
url
!==
false
)
{
html
.
push
(
'
<div>
'
);
html
.
push
(
'
<input placeholder="Enter a URL" class="form-control" style="width:50%; display:none;" type="text" name="
'
.
push
(
'
<input placeholder="
'
+
(
isMultiple
?
'
Enter one or more URLs
'
:
'
Enter a URL
'
)
+
'
" class="form-control" style="width:50%; display:none;" type="text" name="
'
+
name
+
'
_text">
'
);
html
.
push
(
'
</div>
'
);
}
html
.
push
(
'
<input style="display:none;" type="file" name="
'
+
name
+
'
_file">
'
);
+
'
_file"
'
+
(
isMultiple
?
'
multiple
'
:
''
)
+
'
>
'
);
// browse button clicked
// select change
that
.
$form
.
on
(
'
change
'
,
'
[name=
'
+
name
+
'
_picker]
'
,
.
on
(
'
change
'
,
'
[name=
'
+
name
+
'
_picker]
'
,
function
(
evt
)
{
var
$this
=
$
(
this
);
var
val
=
$this
.
val
();
...
...
@@ -603,15 +613,20 @@ morpheus.FormBuilder.prototype = {
var
showTextInput
=
val
===
'
URL
'
;
if
(
'
Dropbox
'
===
val
)
{
var
options
=
{
success
:
function
(
files
)
{
that
.
setValue
(
name
,
files
[
0
].
link
);
success
:
function
(
results
)
{
var
val
=
!
isMultiple
?
results
[
0
].
link
:
results
.
map
(
function
(
result
)
{
return
result
.
link
;
});
that
.
setValue
(
name
,
val
);
that
.
trigger
(
'
change
'
,
{
name
:
name
,
value
:
files
[
0
].
link
value
:
val
});
},
linkType
:
'
direct
'
,
multiselect
:
fals
e
multiselect
:
isMultipl
e
};
Dropbox
.
choose
(
options
);
}
else
if
(
'
My Computer
'
===
val
)
{
...
...
@@ -636,7 +651,7 @@ morpheus.FormBuilder.prototype = {
// browse file selected
that
.
$form
.
on
(
'
change
'
,
'
[name=
'
+
name
+
'
_file]
'
,
function
(
evt
)
{
var
files
=
evt
.
target
.
files
;
// FileList object
that
.
setValue
(
name
,
files
[
0
]);
that
.
setValue
(
name
,
isMultiple
?
files
:
files
[
0
]);
that
.
trigger
(
'
change
'
,
{
name
:
name
,
value
:
files
[
0
]
...
...
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