Make XBlockToXModuleShim use json-init-args to record the XModule constructor to shim to

This commit is contained in:
Calen Pennington
2015-03-27 14:03:46 -04:00
parent 1f17538d42
commit b50876fc32
7 changed files with 22 additions and 11 deletions

View File

@@ -273,7 +273,7 @@ function PollMain(el) {
if (
(tempEl.tagName.toLowerCase() === 'div') &&
($(tempEl).hasClass('xmodule_WrapperModule') === true)
($(tempEl).data('block-type') === 'wrapper')
) {
_this.wrapperSectionEl = tempEl;

View File

@@ -58,14 +58,20 @@
return Descriptor;
}());
this.XBlockToXModuleShim = function (runtime, element) {
this.XBlockToXModuleShim = function (runtime, element, initArgs) {
/*
* Load a single module (either an edit module or a display module)
* from the supplied element, which should have a data-type attribute
* specifying the class to load
*/
var moduleType = $(element).data('type'),
module;
var moduleType, module;
if (initArgs) {
moduleType = initArgs['xmodule-type'];
}
if (!moduleType) {
moduleType = $(element).data('type');
}
if (moduleType === 'None') {
return;

View File

@@ -237,12 +237,13 @@ class HTMLSnippet(object):
.format(self.__class__))
def shim_xmodule_js(fragment):
def shim_xmodule_js(block, fragment):
"""
Set up the XBlock -> XModule shim on the supplied :class:`xblock.fragment.Fragment`
"""
if not fragment.js_init_fn:
fragment.initialize_js('XBlockToXModuleShim')
fragment.json_init_args = {'xmodule-type': block.js_module_name}
class XModuleMixin(XBlockMixin):