Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
b3217496
Commit
b3217496
authored
Sep 02, 2017
by
Louis Jencka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add progress bar to upload form
parent
81219663
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
main.js
cps/static/js/main.js
+25
-0
layout.html
cps/templates/layout.html
+5
-0
No files found.
cps/static/js/main.js
View file @
b3217496
...
@@ -164,6 +164,31 @@ $(function() {
...
@@ -164,6 +164,31 @@ $(function() {
$
(
this
).
find
(
".modal-body"
).
html
(
"..."
);
$
(
this
).
find
(
".modal-body"
).
html
(
"..."
);
});
});
$
(
"#form-upload"
).
ajaxForm
({
beforeSend
:
function
()
{
// Replace upload button with progress bar
$
(
"#upload-bar"
).
width
(
$
(
"#form-upload"
).
width
());
$
(
"#form-upload"
).
hide
();
$
(
"#upload-bar"
).
show
();
var
percentVal
=
"0%"
;
$
(
"#upload-bar-val"
).
width
(
percentVal
);
$
(
"#upload-bar-val"
).
html
(
percentVal
);
},
uploadProgress
:
function
(
event
,
position
,
total
,
percentComplete
)
{
var
percentVal
=
percentComplete
+
"%"
;
$
(
"#upload-bar-val"
).
width
(
percentVal
);
$
(
"#upload-bar-val"
).
html
(
percentVal
);
},
error
:
function
()
{
$
(
"#upload-bar"
).
hide
();
$
(
"#form-upload"
).
show
();
alert
(
"Upload failed."
);
},
type
:
"post"
,
target
:
"html"
});
$
(
window
).
resize
(
function
()
{
$
(
window
).
resize
(
function
()
{
$
(
".discover .row"
).
isotope
(
"reLayout"
);
$
(
".discover .row"
).
isotope
(
"reLayout"
);
});
});
...
...
cps/templates/layout.html
View file @
b3217496
...
@@ -56,6 +56,11 @@
...
@@ -56,6 +56,11 @@
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.user.role_upload() or g.user.role_admin()%}
{% if g.allow_upload %}
{% if g.allow_upload %}
<li>
<li>
<div
id=
"upload-bar"
class=
"navbar-text progress"
style=
"display: none;"
>
<div
id=
"upload-bar-val"
class=
"progress-bar"
>
0%
</div>
</div>
<form
id=
"form-upload"
class=
"navbar-form"
action=
"{{ url_for('upload') }}"
method=
"post"
enctype=
"multipart/form-data"
>
<form
id=
"form-upload"
class=
"navbar-form"
action=
"{{ url_for('upload') }}"
method=
"post"
enctype=
"multipart/form-data"
>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<span
class=
"btn btn-default btn-file"
>
{{_('Upload')}}
<input
id=
"btn-upload"
name=
"btn-upload"
type=
"file"
></span>
<span
class=
"btn btn-default btn-file"
>
{{_('Upload')}}
<input
id=
"btn-upload"
name=
"btn-upload"
type=
"file"
></span>
...
...
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