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
faa35f95
Commit
faa35f95
authored
Sep 29, 2012
by
kimth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move executeProblemScripts into executeModuleScripts
parent
77af8604
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
54 deletions
+47
-54
common/lib/xmodule/xmodule/js/src/capa/display.coffee
+2
-53
common/lib/xmodule/xmodule/js/src/jsloader.coffee
+45
-1
No files found.
common/lib/xmodule/xmodule/js/src/capa/display.coffee
View file @
faa35f95
...
...
@@ -63,7 +63,7 @@ class @Problem
@
new_queued_items
=
$
(
response
.
html
).
find
(
".xqueue"
)
if
@
new_queued_items
.
length
isnt
@
num_queued_items
@
el
.
html
(
response
.
html
)
@
executeProblemScripts
()
=>
JavascriptLoader
.
executeModuleScripts
@
el
,
()
=>
@
setupInputTypes
()
@
bind
()
...
...
@@ -81,10 +81,6 @@ class @Problem
@
setupInputTypes
()
@
bind
()
@
queueing
()
@
executeProblemScripts
()
=>
@
setupInputTypes
()
@
bind
()
@
queueing
()
else
$
.
postWithPrefix
"
#{
@
url
}
/problem_get"
,
(
response
)
=>
@
el
.
html
(
response
.
html
)
...
...
@@ -92,10 +88,7 @@ class @Problem
@
setupInputTypes
()
@
bind
()
@
queueing
()
@
executeProblemScripts
()
=>
@
setupInputTypes
()
@
bind
()
@
queueing
()
# TODO add hooks for problem types here by inspecting response.html and doing
# stuff if a div w a class is found
...
...
@@ -110,50 +103,6 @@ class @Problem
if
setupMethod
?
@
inputtypeDisplays
[
id
]
=
setupMethod
(
inputtype
)
executeProblemScripts
:
(
callback
=
null
)
->
placeholders
=
@
el
.
find
(
".script_placeholder"
)
if
placeholders
.
length
==
0
callback
()
return
completed
=
(
false
for
i
in
[
1
..
placeholders
.
length
])
callbackCalled
=
false
# This is required for IE8 support.
completionHandlerGeneratorIE
=
(
index
)
=>
return
()
->
if
(
this
.
readyState
==
'complete'
||
this
.
readyState
==
'loaded'
)
#completionHandlerGenerator.call(self, index)()
completionHandlerGenerator
(
index
)()
completionHandlerGenerator
=
(
index
)
=>
return
()
=>
allComplete
=
true
completed
[
index
]
=
true
for
flag
in
completed
if
not
flag
allComplete
=
false
break
if
allComplete
and
not
callbackCalled
callbackCalled
=
true
callback
()
if
callback
?
placeholders
.
each
(
index
,
placeholder
)
->
s
=
document
.
createElement
(
'script'
)
s
.
setAttribute
(
'src'
,
$
(
placeholder
).
attr
(
"data-src"
))
s
.
setAttribute
(
'type'
,
"text/javascript"
)
s
.
onload
=
completionHandlerGenerator
(
index
)
# s.onload does not fire in IE8; this does.
s
.
onreadystatechange
=
completionHandlerGeneratorIE
(
index
)
# Need to use the DOM elements directly or the scripts won't execute
# properly.
$
(
'head'
)[
0
].
appendChild
(
s
)
$
(
placeholder
).
remove
()
###
# 'check_fd' uses FormData to allow file submissions in the 'problem_check' dispatch,
...
...
common/lib/xmodule/xmodule/js/src/jsloader.coffee
View file @
faa35f95
...
...
@@ -11,7 +11,51 @@ class @JavascriptLoader
# 3) Explicitly wait for each script to be loaded
# 4) Return to callback function when all scripts loaded
@
executeModuleScripts
:
(
el
,
callback
=
null
)
->
console
.
log
(
'executeModuleScripts'
)
placeholders
=
el
.
find
(
".script_placeholder"
)
if
placeholders
.
length
==
0
callback
()
return
completed
=
(
false
for
i
in
[
1
..
placeholders
.
length
])
callbackCalled
=
false
# This is required for IE8 support.
completionHandlerGeneratorIE
=
(
index
)
=>
return
()
->
if
(
this
.
readyState
==
'complete'
||
this
.
readyState
==
'loaded'
)
#completionHandlerGenerator.call(self, index)()
completionHandlerGenerator
(
index
)()
completionHandlerGenerator
=
(
index
)
=>
return
()
=>
allComplete
=
true
completed
[
index
]
=
true
for
flag
in
completed
if
not
flag
allComplete
=
false
break
if
allComplete
and
not
callbackCalled
callbackCalled
=
true
callback
()
if
callback
?
placeholders
.
each
(
index
,
placeholder
)
->
# TODO: Check if the script already exists in DOM. If so, (1) copy it
# into memory; (2) delete the DOM script element; (3) reappend it
s
=
document
.
createElement
(
'script'
)
s
.
setAttribute
(
'src'
,
$
(
placeholder
).
attr
(
"data-src"
))
s
.
setAttribute
(
'type'
,
"text/javascript"
)
s
.
onload
=
completionHandlerGenerator
(
index
)
# s.onload does not fire in IE8; this does.
s
.
onreadystatechange
=
completionHandlerGeneratorIE
(
index
)
# Need to use the DOM elements directly or the scripts won't execute
# properly.
$
(
'head'
)[
0
].
appendChild
(
s
)
$
(
placeholder
).
remove
()
# setCollapsibles:
...
...
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