Fakultas Ilmu Komputer UI
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
DIGIPUS
Commits
0eba22b8
Commit
0eba22b8
authored
Oct 30, 2020
by
Josh Sudung
Browse files
Implement document preview pre-upload Materi
parent
3d35ca2e
Pipeline
#60034
passed with stages
in 37 minutes and 40 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/templates/app/base_dashboard.html
View file @
0eba22b8
...
...
@@ -24,6 +24,7 @@
<!-- Custom styles for this page -->
<link
href=
"{% static 'vendor/datatables/dataTables.bootstrap4.min.css' %}"
rel=
"stylesheet"
>
{% block stylesheets %}{% endblock %}
{% block scripts %}{% endblock %}
</head>
<body
id=
"page-top"
style=
"font-family: 'Poppins', sans-serif;"
>
...
...
app/templates/unggah.html
View file @
0eba22b8
...
...
@@ -5,6 +5,10 @@
<title>
Unggah Materi | Digipus
</title>
{% endblock %}
{% block scripts %}
<script
src=
"{% static 'js/upload-preview.js' %}"
></script>
{% endblock %}
{% block content %}
<div
class=
"container"
>
<div
class=
"col-20"
>
...
...
@@ -36,6 +40,17 @@
{% if field.help_text %}
<p
class=
"help"
>
{{ field.help_text|safe }}
</p>
{% endif %}
{% if field.name == 'cover' %}
<div
hidden
id=
"frame_cover_parent"
class=
"my-3"
>
<div
class=
"mb-2"
>
Preview Cover:
</div>
<img
id=
"frame_cover"
class=
"constraint-frame"
alt=
"Cover Preview"
/>
</div>
{% elif field.name == 'content' %}
<div
hidden
id=
"frame_content_parent"
class=
"my-3"
>
<div
class=
"mb-2"
>
Preview Content:
</div>
<embed
id=
"frame_content"
width=
"550px"
height=
"550px"
/>
</div>
{% endif %}
</div>
</div>
{% endfor %}
...
...
staticfiles/css/button.css
View file @
0eba22b8
...
...
@@ -117,4 +117,9 @@
.margin-content
{
margin
:
0
;
padding
:
0
;
}
.constraint-frame
{
max-width
:
550px
;
max-height
:
550px
;
}
\ No newline at end of file
staticfiles/js/upload-preview.js
0 → 100644
View file @
0eba22b8
window
.
onload
=
()
=>
{
document
.
querySelector
(
'
input[name="cover"]
'
).
setAttribute
(
"
onchange
"
,
"
preview('frame_cover')
"
);
document
.
querySelector
(
'
input[name="content"]
'
).
setAttribute
(
"
onchange
"
,
"
preview('frame_content')
"
);
}
const
preview
=
(
elementClass
)
=>
{
let
frame
=
document
.
getElementById
(
elementClass
);
let
frameParent
=
document
.
getElementById
(
`
${
elementClass
}
_parent`
);
// Embed elements need to be recreated on source change
if
(
frame
.
nodeName
.
toLowerCase
()
===
'
embed
'
)
{
frameParent
.
removeChild
(
frame
);
frameParent
.
insertAdjacentHTML
(
'
beforeend
'
,
'
<embed id="frame_content" width="550px" height="550px" />
'
);
frame
=
document
.
getElementById
(
elementClass
);
}
frame
.
src
=
URL
.
createObjectURL
(
event
.
target
.
files
[
0
]);
frameParent
.
removeAttribute
(
'
hidden
'
);
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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