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
25e0627e
Commit
25e0627e
authored
Aug 14, 2014
by
jmclaus
Committed by
Carson Gee
Aug 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Supply loading_timeout attribute for jsinput tag.
(cherry picked from commit b7ee0233c9a370428d7473e8ce7c7d73fc471519)
parent
53346ffd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
4 deletions
+27
-4
common/lib/capa/capa/inputtypes.py
+4
-2
common/lib/capa/capa/templates/jsinput.html
+3
-0
common/static/js/capa/src/jsinput.js
+14
-2
docs/en_us/developers/source/extending_platform/javascript.rst
+6
-0
No files found.
common/lib/capa/capa/inputtypes.py
View file @
25e0627e
...
...
@@ -585,8 +585,10 @@ class JSInput(InputTypeBase):
# set state
Attribute
(
'width'
,
"400"
),
# iframe width
Attribute
(
'height'
,
"300"
),
# iframe height
Attribute
(
'sop'
,
None
)
# SOP will be relaxed only if this
# attribute is set to false.
Attribute
(
'sop'
,
None
),
# SOP will be relaxed only if this
# attribute is set to false.
Attribute
(
'loading_timeout'
,
None
)
# Timeout that is used when
# loading JS application.
]
def
_extra_context
(
self
):
...
...
common/lib/capa/capa/templates/jsinput.html
View file @
25e0627e
...
...
@@ -15,6 +15,9 @@
%
if
sop:
data-sop=
"${sop}"
%
endif
%
if
loading_timeout:
data-loading-timeout=
"${loading_timeout}"
%
endif
data-processed=
"false"
>
...
...
common/static/js/capa/src/jsinput.js
View file @
25e0627e
...
...
@@ -32,6 +32,7 @@ var JSInput = (function ($, undefined) {
/* END Utils */
var
loadingTimeout
=
300
;
function
jsinputConstructor
(
elem
)
{
// Define an class that will be instantiated for each jsinput element
...
...
@@ -205,15 +206,26 @@ var JSInput = (function ($, undefined) {
});
}
function
getLoadingTimeout
()
{
var
allSections
=
$
(
'section.jsinput'
),
timeout
;
allSections
.
each
(
function
(
index
,
value
)
{
timeout
=
$
(
value
).
attr
(
"data-loading-timeout"
);
if
(
timeout
&&
isFinite
(
timeout
))
{
loadingTimeout
=
Math
.
max
(
loadingTimeout
,
timeout
);
}
});
}
// This is ugly, but without a timeout pages with multiple/heavy jsinputs
// don't load properly.
// 300 ms is arbitrary but this has functioned with the only application
// that has ever used JSInput, jsVGL. Something more sturdy should be put in
// place.
getLoadingTimeout
();
if
(
$
.
isReady
)
{
setTimeout
(
walkDOM
,
300
);
setTimeout
(
walkDOM
,
loadingTimeout
);
}
else
{
$
(
document
).
ready
(
setTimeout
(
walkDOM
,
300
));
$
(
document
).
ready
(
setTimeout
(
walkDOM
,
loadingTimeout
));
}
return
{
...
...
docs/en_us/developers/source/extending_platform/javascript.rst
View file @
25e0627e
...
...
@@ -313,3 +313,9 @@ The following table describes the attributes of the ``jsinput`` element.
- The same-origin policy (SOP), meaning that all elements have the same
protocol, host, and port. To bypass the SOP, set to ``true``.
- false
* - loading_timeout
- Timeout (in ms) that lets a heavy JS application load before JSInput is
initialized. If multiple JSInput have the above parameter set and are
included in a page, the largest value will be retained.
- 300
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