Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
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
edx
edx-platform
Commits
820a2b40
Commit
820a2b40
authored
Apr 10, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add in js image upload preview
parent
9f04769c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletions
+11
-1
common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee
+11
-1
No files found.
common/lib/xmodule/xmodule/js/src/combinedopenended/display.coffee
View file @
820a2b40
...
...
@@ -491,8 +491,10 @@ class @CombinedOpenEnded
if
@
accept_file_upload
==
"True"
if
window
.
File
and
window
.
FileReader
and
window
.
FileList
and
window
.
Blob
@
can_upload_files
=
true
@
file_upload_area
.
html
(
'<input type="file" class="file-upload-box">'
)
@
file_upload_area
.
html
(
'<input type="file" class="file-upload-box">
<img class="file-upload-preview" src="#" alt="Uploaded image" />
'
)
@
file_upload_area
.
show
()
$
(
'.file-upload-preview'
).
hide
()
$
(
'.file-upload-box'
).
change
@
preview_image
else
@
gentle_alert
'File uploads are required for this question, but are not supported in this browser. Try the newest version of google chrome. Alternatively, if you have uploaded the image to the web, you can paste a link to it into the answer box.'
...
...
@@ -548,3 +550,11 @@ class @CombinedOpenEnded
log_feedback_selection
:
(
event
)
->
target_selection
=
$
(
event
.
target
).
val
()
Logger
.
log
'oe_feedback_response_selected'
,
{
value
:
target_selection
}
preview_image
:
()
=>
if
$
(
'.file-upload-box'
)[
0
].
files
&&
$
(
'.file-upload-box'
)[
0
].
files
[
0
]
reader
=
new
FileReader
()
reader
.
onload
=
(
e
)
=>
$
(
'.file-upload-preview'
).
attr
(
'src'
,
e
.
target
.
result
).
width
(
150
).
height
(
150
)
$
(
'.file-upload-preview'
).
show
()
reader
.
readAsDataURL
(
$
(
'.file-upload-box'
)[
0
].
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