Commit 982c3e62 by Sven Marnach

Pass DOM element, not jQuery object to XBlock initialisation.

The function initializeXBlock() expects a DOM element, and is passed one in most
cases.  However, when adding a new XBlock component in Studio, the function is
passed a jQuery object, which ends up being forwarded to the actual
initialisation function of the XBlock.
parent 9fd6bef3
...@@ -43,7 +43,7 @@ define(["jquery", "underscore", "common/js/components/utils/view_utils", "js/vie ...@@ -43,7 +43,7 @@ define(["jquery", "underscore", "common/js/components/utils/view_utils", "js/vie
fragmentsRendered.always(function() { fragmentsRendered.always(function() {
xblockElement = self.$('.xblock').first(); xblockElement = self.$('.xblock').first();
try { try {
xblock = XBlock.initializeBlock(xblockElement); xblock = XBlock.initializeBlock(xblockElement.get(0));
self.xblock = xblock; self.xblock = xblock;
self.xblockReady(xblock); self.xblockReady(xblock);
if (successCallback) { if (successCallback) {
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
'use strict'; 'use strict';
function VisibilityEditorView(runtime, element) { function VisibilityEditorView(runtime, element) {
var $element = $(element);
this.getGroupAccess = function() { this.getGroupAccess = function() {
var groupAccess = {}, var groupAccess = {},
checkboxValues, checkboxValues,
...@@ -15,12 +16,12 @@ ...@@ -15,12 +16,12 @@
// defined by VerificationPartitionScheme on the backend! // defined by VerificationPartitionScheme on the backend!
ALLOW_GROUP_ID = 1; ALLOW_GROUP_ID = 1;
if (element.find('.visibility-level-all').prop('checked')) { if ($element.find('.visibility-level-all').prop('checked')) {
return {}; return {};
} }
// Cohort partitions (user is allowed to select more than one) // Cohort partitions (user is allowed to select more than one)
element.find('.field-visibility-content-group input:checked').each(function(index, input) { $element.find('.field-visibility-content-group input:checked').each(function(index, input) {
checkboxValues = $(input).val().split("-"); checkboxValues = $(input).val().split("-");
partitionId = parseInt(checkboxValues[0], 10); partitionId = parseInt(checkboxValues[0], 10);
groupId = parseInt(checkboxValues[1], 10); groupId = parseInt(checkboxValues[1], 10);
...@@ -33,7 +34,7 @@ ...@@ -33,7 +34,7 @@
}); });
// Verification partitions (user can select exactly one) // Verification partitions (user can select exactly one)
if (element.find('#verification-access-checkbox').prop('checked')) { if ($element.find('#verification-access-checkbox').prop('checked')) {
partitionId = parseInt($('#verification-access-dropdown').val(), 10); partitionId = parseInt($('#verification-access-dropdown').val(), 10);
groupAccess[partitionId] = [ALLOW_GROUP_ID]; groupAccess[partitionId] = [ALLOW_GROUP_ID];
} }
...@@ -42,19 +43,19 @@ ...@@ -42,19 +43,19 @@
}; };
// When selecting "all students and staff", uncheck the specific groups // When selecting "all students and staff", uncheck the specific groups
element.find('.field-visibility-level input').change(function(event) { $element.find('.field-visibility-level input').change(function(event) {
if ($(event.target).hasClass('visibility-level-all')) { if ($(event.target).hasClass('visibility-level-all')) {
element.find('.field-visibility-content-group input, .field-visibility-verification input') $element.find('.field-visibility-content-group input, .field-visibility-verification input')
.prop('checked', false); .prop('checked', false);
} }
}); });
// When selecting a specific group, deselect "all students and staff" and // When selecting a specific group, deselect "all students and staff" and
// select "specific content groups" instead.` // select "specific content groups" instead.`
element.find('.field-visibility-content-group input, .field-visibility-verification input') $element.find('.field-visibility-content-group input, .field-visibility-verification input')
.change(function() { .change(function() {
element.find('.visibility-level-all').prop('checked', false); $element.find('.visibility-level-all').prop('checked', false);
element.find('.visibility-level-specific').prop('checked', true); $element.find('.visibility-level-specific').prop('checked', true);
}); });
} }
......
...@@ -26,7 +26,7 @@ class @HTMLEditingDescriptor ...@@ -26,7 +26,7 @@ class @HTMLEditingDescriptor
CUSTOM_FONTS + STANDARD_FONTS CUSTOM_FONTS + STANDARD_FONTS
constructor: (element) -> constructor: (element) ->
@element = element @element = $(element)
@base_asset_url = @element.find("#editor-tab").data('base-asset-url') @base_asset_url = @element.find("#editor-tab").data('base-asset-url')
@editor_choice = @element.find("#editor-tab").data('editor') @editor_choice = @element.find("#editor-tab").data('editor')
if @base_asset_url == undefined if @base_asset_url == undefined
......
...@@ -13,7 +13,7 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor ...@@ -13,7 +13,7 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
@explanationTemplate: "[explanation]\n#{gettext 'Short explanation'}\n[explanation]\n" @explanationTemplate: "[explanation]\n#{gettext 'Short explanation'}\n[explanation]\n"
constructor: (element) -> constructor: (element) ->
@element = element @element = $(element)
if $(".markdown-box", @element).length != 0 if $(".markdown-box", @element).length != 0
@markdown_editor = CodeMirror.fromTextArea($(".markdown-box", element)[0], { @markdown_editor = CodeMirror.fromTextArea($(".markdown-box", element)[0], {
......
...@@ -2,7 +2,7 @@ class @TabsEditingDescriptor ...@@ -2,7 +2,7 @@ class @TabsEditingDescriptor
@isInactiveClass : "is-inactive" @isInactiveClass : "is-inactive"
constructor: (element) -> constructor: (element) ->
@element = element; @element = $(element)
### ###
Not tested on syncing of multiple editors of same type in tabs Not tested on syncing of multiple editors of same type in tabs
(Like many CodeMirrors). (Like many CodeMirrors).
......
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
} else { } else {
block = {}; block = {};
} }
block.element = element; block.element = $element;
block.name = $element.data('name'); block.name = $element.data('name');
block.type = $element.data('block-type'); block.type = $element.data('block-type');
$element.trigger('xblock-initialized'); $element.trigger('xblock-initialized');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment