Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
865e43ed
Commit
865e43ed
authored
6 years ago
by
Calen Pennington
Browse files
Options
Downloads
Patches
Plain Diff
Delay initialization of XBlocks until after all fragments have been rendered
parent
8d342689
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/lib/xmodule/xmodule/js/src/conditional/display.js
+16
-17
16 additions, 17 deletions
common/lib/xmodule/xmodule/js/src/conditional/display.js
common/lib/xmodule/xmodule/js/src/sequence/display.js
+5
-5
5 additions, 5 deletions
common/lib/xmodule/xmodule/js/src/sequence/display.js
with
21 additions
and
22 deletions
common/lib/xmodule/xmodule/js/src/conditional/display.js
+
16
−
17
View file @
865e43ed
...
...
@@ -21,11 +21,11 @@
Conditional
.
prototype
.
render
=
function
(
element
)
{
return
$
.
postWithPrefix
(
this
.
url
+
"
/conditional_get
"
,
(
function
(
_this
)
{
return
function
(
response
)
{
var
i
,
len
,
parentEl
,
parentId
,
ref
;
var
i
,
len
,
parentEl
,
parentId
,
ref
,
renderedFragments
=
[]
;
_this
.
el
.
html
(
''
);
fragments
=
response
.
fragments
;
for
(
i
=
0
,
len
=
fragments
.
length
;
i
<
len
;
i
++
)
{
_this
.
renderXBlockFragment
(
fragments
[
i
]);
renderedFragments
.
push
(
_this
.
renderXBlockFragment
(
fragments
[
i
])
)
;
}
parentEl
=
$
(
element
).
parent
();
parentId
=
parentEl
.
attr
(
'
id
'
);
...
...
@@ -47,7 +47,9 @@
The children are rendered with a new request, so they have a different request-token.
Use that token instead of @requestToken by simply not passing a token into initializeBlocks.
*/
return
XBlock
.
initializeBlocks
(
_this
.
el
);
$
.
when
.
apply
(
null
,
renderedFragments
).
done
(
function
()
{
XBlock
.
initializeBlocks
(
_this
.
el
);
});
};
})(
this
));
};
...
...
@@ -65,7 +67,6 @@
Conditional
.
prototype
.
renderXBlockFragment
=
function
(
fragment
)
{
var
html
=
fragment
.
content
,
resources
=
fragment
.
resources
||
[],
blockView
=
this
,
element
=
this
.
el
;
// Render the HTML first as the scripts might depend upon it, and then
// asynchronously add the resources to the page. Any errors that are thrown
...
...
@@ -91,12 +92,13 @@
* @returns {Promise} A promise representing the rendering process
*/
Conditional
.
prototype
.
addXBlockFragmentResources
=
function
(
resources
)
{
var
self
=
this
,
applyResource
,
numResources
,
deferred
;
numResources
=
resources
.
length
;
deferred
=
$
.
Deferred
();
var
self
=
this
;
var
applyResource
;
var
numResources
;
var
deferred
;
var
numResources
=
resources
.
length
;
var
deferred
=
$
.
Deferred
();
applyResource
=
function
(
index
)
{
var
hash
,
resource
,
value
,
promise
;
if
(
index
>=
numResources
)
{
...
...
@@ -104,12 +106,10 @@
return
;
}
resource
=
resources
[
index
];
if
(
!
window
.
loadedXBlockResources
)
{
window
.
loadedXBlockResources
=
[];
}
if
(
_
.
indexOf
(
window
.
loadedXBlockResources
,
resource
)
<
0
)
{
window
.
loadedXBlockResources
=
window
.
loadedXBlockResources
||
[];
if
(
_
.
indexOf
(
loadedXBlockResources
,
resource
)
<
0
)
{
promise
=
self
.
loadResource
(
resource
);
window
.
loadedXBlockResources
.
push
(
resource
);
loadedXBlockResources
.
push
(
resource
);
promise
.
done
(
function
()
{
applyResource
(
index
+
1
);
}).
fail
(
function
()
{
...
...
@@ -146,8 +146,7 @@
}
}
else
if
(
mimetype
===
'
application/javascript
'
)
{
if
(
kind
===
'
text
'
)
{
// xss-lint: disable=javascript-jquery-append,javascript-concat-html
$head
.
append
(
'
<script>
'
+
data
+
'
</script>
'
);
eval
.
call
(
window
,
data
);
}
else
if
(
kind
===
'
url
'
)
{
// This is a dependency loaded from the LMS (not ideal)
return
ViewUtils
.
loadJavaScript
(
data
);
...
...
This diff is collapsed.
Click to expand it.
common/lib/xmodule/xmodule/js/src/sequence/display.js
+
5
−
5
View file @
865e43ed
...
...
@@ -233,13 +233,13 @@
if
(
this
.
position
)
{
this
.
mark_visited
(
this
.
position
);
if
(
this
.
showCompletion
)
{
this
.
update_completion
(
this
.
position
);
this
.
update_completion
(
this
.
position
);
}
if
(
this
.
savePosition
)
{
modxFullUrl
=
''
+
this
.
ajaxUrl
+
'
/goto_position
'
;
$
.
postWithPrefix
(
modxFullUrl
,
{
position
:
newPosition
});
modxFullUrl
=
''
+
this
.
ajaxUrl
+
'
/goto_position
'
;
$
.
postWithPrefix
(
modxFullUrl
,
{
position
:
newPosition
});
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment