Skip to content

Commit

Permalink
Merge branch 'release-12.41.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Dec 11, 2023
2 parents cec7d7f + 0a19333 commit 4652de8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion views/js/loader/taoMediaManager.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoMediaManager.min.js.map

Large diffs are not rendered by default.

35 changes: 18 additions & 17 deletions views/js/qtiCreator/renderers/Img.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,36 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2020 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
* Copyright (c) 2020-2023 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT);
*/

define([
'lodash',
'context',
'taoQtiItem/qtiCommonRenderer/renderers/Img',
'taoMediaManager/qtiCreator/widgets/static/img/Widget',
'taoQtiItem/qtiCreator/widgets/static/figure/Widget',
'taoQtiItem/qtiCreator/model/Figure',
'taoQtiItem/qtiCreator/helper/findParentElement'
], function (_, Renderer, Widget, FigureWidget, FigureModel, findParentElement) {
], function (_, context, Renderer, Widget, FigureWidget, FigureModel, findParentElement) {
'use strict';

const CreatorImg = _.clone(Renderer);

const DISABLE_FIGURE_WIDGET = context.featureFlags['FEATURE_FLAG_DISABLE_FIGURE_WIDGET'];

CreatorImg.render = function render(img, options) {
const $container = Renderer.getContainer(img);
if ($container.parent('figure').length || $container.parent('span').length && $container.parent('span').data('figure')) {
if (
$container.parent('figure').length ||
(!DISABLE_FIGURE_WIDGET && $container.parent('span').length && $container.parent('span').data('figure'))
) {
// don't create widget if has figure parent
if (!$container.parent('figure').length && $container.siblings('figcaption').length) {
if (
!DISABLE_FIGURE_WIDGET &&
!$container.parent('figure').length &&
$container.siblings('figcaption').length
) {
$container.siblings('figcaption').remove();
}
return CreatorImg;
Expand All @@ -46,6 +56,7 @@ define([
options.assetManager = this.getAssetManager();

if (
!DISABLE_FIGURE_WIDGET &&
!$container.closest('.qti-choice, .qti-flow-container').length &&
!$container.closest('.qti-table caption').length
) {
Expand All @@ -56,23 +67,13 @@ define([
const figureRenderer = parent.getRenderer();
if (figureRenderer) {
figure.setRenderer(figureRenderer);
figureRenderer.load(() => { }, ['figure']);
figureRenderer.load(() => {}, ['figure']);
}
figure.setElement(img);
const $wrap = $container.wrap(`<span data-serial="${figure.serial}">`).parent();
FigureWidget.build(
figure,
$wrap,
this.getOption('bodyElementOptionForm'),
options
);
FigureWidget.build(figure, $wrap, this.getOption('bodyElementOptionForm'), options);
} else {
Widget.build(
img,
Renderer.getContainer(img),
this.getOption('bodyElementOptionForm'),
options
);
Widget.build(img, Renderer.getContainer(img), this.getOption('bodyElementOptionForm'), options);
}
};

Expand Down
9 changes: 6 additions & 3 deletions views/js/qtiCreator/widgets/static/figure/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,26 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2022 (original work) Open Assessment Technologies SA ;
* Copyright (c) 2022-2023 (original work) Open Assessment Technologies SA ;
*
*/
define([
'jquery',
'lodash',
'context',
'taoQtiItem/qtiCreator/widgets/static/Widget',
'taoMediaManager/qtiCreator/widgets/static/figure/states/states',
'taoQtiItem/qtiCreator/widgets/static/helpers/widget',
'tpl!taoQtiItem/qtiCreator/tpl/toolbars/media',
'taoQtiItem/qtiCreator/widgets/static/helpers/inline',
'ui/mediaEditor/plugins/mediaAlignment/helper'
], function ($, _, Widget, states, helper, toolbarTpl, inlineHelper, alignmentHelper) {
], function ($, _, context, Widget, states, helper, toolbarTpl, inlineHelper, alignmentHelper) {
'use strict';

const FigureWidget = Widget.clone();

const DISABLE_FIGURE_WIDGET = context.featureFlags['FEATURE_FLAG_DISABLE_FIGURE_WIDGET'];

FigureWidget.initCreator = function initCreator(options) {
const figure = this.element;
const img = _.find(figure.getBody().elements, elem => elem.is('img'));
Expand Down Expand Up @@ -61,7 +64,7 @@ define([
};

FigureWidget.buildContainer = function buildContainer() {
if (this.element.attr('showFigure')) {
if (DISABLE_FIGURE_WIDGET || this.element.attr('showFigure')) {
// If it is aligned to left or right, it will have FigCaption and will need Figure tag
helper.buildBlockContainer(this);
} else {
Expand Down

0 comments on commit 4652de8

Please sign in to comment.