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
b7eea135
Commit
b7eea135
authored
Jun 18, 2014
by
Christina Roberts
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4119 from edx/christina/requirejs-promise
Wait for scripts defined in common xmodule code to execute.
parents
7a452b62
3acf394d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
36 deletions
+48
-36
cms/templates/container.html
+9
-10
cms/templates/edit-tabs.html
+12
-10
cms/templates/unit.html
+16
-14
common/djangoapps/pipeline_js/templates/xmodule.js
+11
-2
No files found.
cms/templates/container.html
View file @
b7eea135
...
...
@@ -32,19 +32,18 @@ main_xblock_info = {
<script
type=
'text/javascript'
>
require
([
"domReady!"
,
"jquery"
,
"js/models/xblock_info"
,
"js/views/pages/container"
,
"js/collections/component_template"
,
"xmodule"
,
"coffee/src/main"
,
"xblock/cms.runtime.v1"
],
function
(
doc
,
$
,
XBlockInfo
,
ContainerPage
,
ComponentTemplates
)
{
var
view
,
mainXBlockInfo
;
function
(
doc
,
$
,
XBlockInfo
,
ContainerPage
,
ComponentTemplates
,
xmoduleLoader
)
{
var
templates
=
new
ComponentTemplates
(
$
{
component_templates
|
n
},
{
parse
:
true
});
var
mainXBlockInfo
=
new
XBlockInfo
(
$
{
json
.
dumps
(
main_xblock_info
)
|
n
});
mainXBlockInfo
=
new
XBlockInfo
(
$
{
json
.
dumps
(
main_xblock_info
)
|
n
});
view
=
new
ContainerPage
({
el
:
$
(
'#content'
),
model
:
mainXBlockInfo
,
templates
:
templates
xmoduleLoader
.
done
(
function
()
{
var
view
=
new
ContainerPage
({
el
:
$
(
'#content'
),
model
:
mainXBlockInfo
,
templates
:
templates
});
view
.
render
();
});
view
.
render
();
});
</script>
...
...
cms/templates/edit-tabs.html
View file @
b7eea135
...
...
@@ -21,16 +21,18 @@
<script
type=
'text/javascript'
>
require
([
"js/models/explicit_url"
,
"coffee/src/views/tabs"
,
"xmodule"
,
"coffee/src/main"
,
"xblock/cms.runtime.v1"
],
function
(
TabsModel
,
TabsEditView
)
{
var
model
=
new
TabsModel
({
id
:
"${context_course.location}"
,
explicit_url
:
"${reverse('contentstore.views.tabs_handler', kwargs={'course_key_string': context_course.id})}"
});
new
TabsEditView
({
el
:
$
(
'.tab-list'
),
model
:
model
,
mast
:
$
(
'.wrapper-mast'
)
function
(
TabsModel
,
TabsEditView
,
xmoduleLoader
)
{
xmoduleLoader
.
done
(
function
()
{
var
model
=
new
TabsModel
({
id
:
"${context_course.location}"
,
explicit_url
:
"${reverse('contentstore.views.tabs_handler', kwargs={'course_key_string': context_course.id})}"
});
new
TabsEditView
({
el
:
$
(
'.tab-list'
),
model
:
model
,
mast
:
$
(
'.wrapper-mast'
)
});
});
});
</script>
...
...
cms/templates/unit.html
View file @
b7eea135
...
...
@@ -21,25 +21,27 @@ from django.utils.translation import ugettext as _
<
%
block
name=
"jsextra"
>
<script
type=
'text/javascript'
>
require
([
"domReady!"
,
"jquery"
,
"js/models/module_info"
,
"coffee/src/views/unit"
,
"js/collections/component_template"
,
"
jquery.ui"
,
"xmodule
"
,
"coffee/src/main"
,
"xblock/cms.runtime.v1"
],
function
(
doc
,
$
,
ModuleModel
,
UnitEditView
,
ComponentTemplates
)
{
"
xmodule"
,
"jquery.ui
"
,
"coffee/src/main"
,
"xblock/cms.runtime.v1"
],
function
(
doc
,
$
,
ModuleModel
,
UnitEditView
,
ComponentTemplates
,
xmoduleLoader
)
{
window
.
unit_location_analytics
=
'${unit_usage_key}'
;
var
templates
=
new
ComponentTemplates
(
$
{
component_templates
|
n
},
{
parse
:
true
});
new
UnitEditView
({
el
:
$
(
'.main-wrapper'
),
view
:
'unit'
,
model
:
new
ModuleModel
({
id
:
'${unit_usage_key}'
,
state
:
'${unit_state}'
}),
templates
:
templates
});
xmoduleLoader
.
done
(
function
()
{
new
UnitEditView
({
el
:
$
(
'.main-wrapper'
),
view
:
'unit'
,
model
:
new
ModuleModel
({
id
:
'${unit_usage_key}'
,
state
:
'${unit_state}'
}),
templates
:
templates
});
$
(
'.new-component-template'
).
each
(
function
(){
$emptyEditor
=
$
(
this
).
find
(
'.empty'
);
$
(
this
).
prepend
(
$emptyEditor
);
$
(
'.new-component-template'
).
each
(
function
(){
$emptyEditor
=
$
(
this
).
find
(
'.empty'
);
$
(
this
).
prepend
(
$emptyEditor
);
});
});
});
</script>
...
...
common/djangoapps/pipeline_js/templates/xmodule.js
View file @
b7eea135
...
...
@@ -21,8 +21,17 @@ define(["jquery", "underscore", "mathjax", "codemirror", "tinymce",
var
urls
=
$
{
urls
};
var
head
=
$
(
"head"
);
$
.
each
(
urls
,
function
(
i
,
url
)
{
var
deferred
=
$
.
Deferred
();
var
numResources
=
urls
.
length
;
$
.
each
(
urls
,
function
(
i
,
url
)
{
head
.
append
(
$
(
"<script/>"
,
{
src
:
url
}));
// Wait for all the scripts to execute.
require
([
url
],
function
()
{
if
(
i
===
numResources
-
1
)
{
deferred
.
resolve
();
}
});
});
return
window
.
XModule
;
return
deferred
.
promise
();
});
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