-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2428 from oat-sa/feature/BSA-391/allow-to-disable…
…-figure-widgets Feature/BSA-391/Allow to disable figure widgets
- Loading branch information
Showing
8 changed files
with
83 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,39 @@ | ||
define([ | ||
'context', | ||
'taoQtiItem/qtiCreator/widgets/states/factory', | ||
'taoQtiItem/qtiCreator/widgets/static/states/Sleep', | ||
'taoQtiItem/qtiCreator/editor/gridEditor/content' | ||
], function(stateFactory, SleepState, contentHelper){ | ||
], function (context, stateFactory, SleepState, contentHelper) { | ||
const DISABLE_FIGURE_WIDGET = context.featureFlags['FEATURE_FLAG_DISABLE_FIGURE_WIDGET']; | ||
|
||
var TextBlockStateSleep = stateFactory.extend(SleepState, function(){ | ||
const widget = this.widget; | ||
widget.afterStateExit(function(e, element, state){ | ||
const serial = element.getSerial(); | ||
if (state.name === 'active' && serial !== widget.serial && (element.qtiClass === 'include' || element.qtiClass === 'figure')){ | ||
// update bdy of container in case include is wrapped in custom-include-box | ||
const composingElts = widget.element.getComposingElements(); | ||
if(composingElts[serial]){ | ||
const $pseudoContainer = $('<div>').html(widget.$container.find('[data-html-editable="true"]').html()); | ||
const newBody = contentHelper.getContent($pseudoContainer); | ||
const container = widget.element; | ||
container.body(newBody); | ||
const TextBlockStateSleep = stateFactory.extend( | ||
SleepState, | ||
function () { | ||
const widget = this.widget; | ||
widget.afterStateExit(function (e, element, state) { | ||
const serial = element.getSerial(); | ||
if ( | ||
state.name === 'active' && | ||
serial !== widget.serial && | ||
(element.qtiClass === 'include' || (!DISABLE_FIGURE_WIDGET && element.qtiClass === 'figure')) | ||
) { | ||
// update bdy of container in case include is wrapped in custom-include-box | ||
const composingElts = widget.element.getComposingElements(); | ||
if (composingElts[serial]) { | ||
const $pseudoContainer = $('<div>').html( | ||
widget.$container.find('[data-html-editable="true"]').html() | ||
); | ||
const newBody = contentHelper.getContent($pseudoContainer); | ||
const container = widget.element; | ||
container.body(newBody); | ||
} | ||
} | ||
} | ||
}, 'question'); | ||
}, function(){ | ||
this.widget.offEvents('question'); | ||
}); | ||
}, 'question'); | ||
}, | ||
function () { | ||
this.widget.offEvents('question'); | ||
} | ||
); | ||
|
||
return TextBlockStateSleep; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters