@oat-sa/tao-core-ui 1.63.0 → 1.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -552,11 +552,13 @@ define(['jquery', 'nouislider', 'ui/resourcemgr', 'ui/tooltip', 'lodash', 'i18n'
552
552
  } = _ref2;
553
553
  const imageElem = getImageElement(widget);
554
554
  const figcaptionElem = getCaptionElement(widget);
555
+ const showFigure = widget.element.attr('showFigure');
555
556
  widget.$form.html(formTpl({
556
557
  baseUrl: widget.options.baseUrl || '',
557
558
  src: imageElem.attr('src'),
558
559
  alt: imageElem.attr('alt'),
559
- figcaption: figcaptionElem ? figcaptionElem.body() : ''
560
+ figcaption: figcaptionElem ? figcaptionElem.body() : '',
561
+ showFigure: showFigure
560
562
  }));
561
563
  widget.$form.find('textarea#figcaption').on('focus.qti-widget', () => widget.$container.addClass('edit-figcaption')).on('blur.qti-widget', () => widget.$container.removeClass('edit-figcaption'));
562
564
 
@@ -574,7 +576,23 @@ define(['jquery', 'nouislider', 'ui/resourcemgr', 'ui/tooltip', 'lodash', 'i18n'
574
576
  togglePlaceholder
575
577
  }));
576
578
  };
577
- function FigureStateActive (stateFactory, ActiveState, formTpl, formElement, inlineHelper) {
579
+
580
+ /**
581
+ * @param {Object} stateFactory
582
+ * @param {Object} ActiveState
583
+ * @param {Object} formTpl
584
+ * @param {Object} formElement
585
+ * @param {Object} inlineHelper
586
+ * @returns
587
+ */
588
+ function FigureStateActive (_ref3) {
589
+ let {
590
+ stateFactory,
591
+ ActiveState,
592
+ formTpl,
593
+ formElement,
594
+ inlineHelper
595
+ } = _ref3;
578
596
  /**
579
597
  * media Editor instance if has been initialized
580
598
  * @type {null}
@@ -582,7 +600,7 @@ define(['jquery', 'nouislider', 'ui/resourcemgr', 'ui/tooltip', 'lodash', 'i18n'
582
600
  let mediaEditor = null;
583
601
  let textareaObserver = null;
584
602
  let texareaHTMLElem = null;
585
- const ImgStateActive = stateFactory.extend(ActiveState, function () {
603
+ const FigureStateActive = stateFactory.extend(ActiveState, function () {
586
604
  this.initForm();
587
605
  }, function () {
588
606
  this.widget.$form.find('textarea#figcaption').off('.qti-widget');
@@ -591,7 +609,7 @@ define(['jquery', 'nouislider', 'ui/resourcemgr', 'ui/tooltip', 'lodash', 'i18n'
591
609
  }
592
610
  this.widget.$form.empty();
593
611
  });
594
- ImgStateActive.prototype.initForm = function () {
612
+ FigureStateActive.prototype.initForm = function () {
595
613
  initForm({
596
614
  widget: this.widget,
597
615
  formElement,
@@ -612,7 +630,7 @@ define(['jquery', 'nouislider', 'ui/resourcemgr', 'ui/tooltip', 'lodash', 'i18n'
612
630
  }
613
631
  }
614
632
  };
615
- return ImgStateActive;
633
+ return FigureStateActive;
616
634
  }
617
635
 
618
636
  return FigureStateActive;
@@ -1,4 +1,6 @@
1
- define(['exports'], function (exports) { 'use strict';
1
+ define(['exports', 'lodash'], function (exports, _) { 'use strict';
2
+
3
+ _ = _ && Object.prototype.hasOwnProperty.call(_, 'default') ? _['default'] : _;
2
4
 
3
5
  /**
4
6
  * This program is free software; you can redistribute it and/or
@@ -17,9 +19,30 @@ define(['exports'], function (exports) { 'use strict';
17
19
  *
18
20
  * Copyright (c) 2021-2022 (original work) Open Assessment Technologies SA;
19
21
  */
20
-
21
22
  const FLOAT_LEFT_CLASS = 'wrap-left';
22
23
  const FLOAT_RIGHT_CLASS = 'wrap-right';
24
+ const searchRecurse = (parentElement, serial) => {
25
+ if (!parentElement) {
26
+ return null;
27
+ }
28
+ if (parentElement.serial === serial) {
29
+ return parentElement;
30
+ }
31
+ let found = null;
32
+ _.some(parentElement['elements'], childElement => {
33
+ if (childElement.serial === serial) {
34
+ found = parentElement;
35
+ } else if (childElement['elements']) {
36
+ found = searchRecurse(childElement, serial);
37
+ } else if (childElement['prompt']) {
38
+ found = searchRecurse(childElement.prompt.bdy, serial);
39
+ }
40
+ if (found) {
41
+ return true;
42
+ }
43
+ });
44
+ return found;
45
+ };
23
46
  const positionFloat = function positionFloat(widget, position) {
24
47
  if (!position) {
25
48
  return;
@@ -41,11 +64,35 @@ define(['exports'], function (exports) { 'use strict';
41
64
  // Update DOM
42
65
  widget.$container.addClass(className);
43
66
  // Update model
67
+ const prevClassName = widget.element.attr('class') || '';
44
68
  if (className) {
45
69
  widget.element.attr('class', className);
46
70
  } else {
47
71
  widget.element.removeAttr('class');
48
72
  }
73
+ if (prevClassName !== className) {
74
+ // Re-build Figure widget to toggle between inline/block
75
+ const parent = searchRecurse(widget.element.bdy.rootElement.bdy, widget.serial);
76
+ // avoid changes on Figure in a prompt
77
+ if (parent.contentModel && parent.contentModel === 'inlineStatic') {
78
+ _.defer(() => {
79
+ widget.element.data('widget').refresh();
80
+ });
81
+ return;
82
+ }
83
+ widget.element.data('widget').changeState('sleep');
84
+ _.defer(() => {
85
+ if (parent && parent.data('widget')) {
86
+ parent.data('widget').changeState('active');
87
+ _.defer(() => {
88
+ parent.data('widget').changeState('sleep');
89
+ _.defer(() => {
90
+ widget.element.data('widget').changeState('active');
91
+ });
92
+ });
93
+ }
94
+ });
95
+ }
49
96
  widget.$original.trigger('contentChange.qti-widget');
50
97
  };
51
98
  const initAlignment = function initAlignment(widget) {
@@ -156,7 +156,6 @@ define(['jquery', 'lodash', 'ui/component', 'handlebars', 'i18n', 'lib/dompurify
156
156
  *
157
157
  * Copyright (c) 2021-2022 (original work) Open Assessment Technologies SA;
158
158
  */
159
-
160
159
  const FLOAT_LEFT_CLASS = 'wrap-left';
161
160
  const FLOAT_RIGHT_CLASS = 'wrap-right';
162
161
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oat-sa/tao-core-ui",
3
- "version": "1.63.0",
3
+ "version": "1.63.1",
4
4
  "displayName": "TAO Core UI",
5
5
  "description": "UI libraries of TAO",
6
6
  "scripts": {
@@ -148,3 +148,7 @@
148
148
  .bg-error {
149
149
  background-color: $errorBgColor;
150
150
  }
151
+
152
+ textarea + .feedback-info {
153
+ padding: 5px;
154
+ }
package/src/css/basic.css CHANGED
@@ -1827,6 +1827,10 @@ html .txt-user-highlight {
1827
1827
  background-color: #f1d0d5;
1828
1828
  }
1829
1829
 
1830
+ textarea + .feedback-info, textarea + .tooltip-blue {
1831
+ padding: 5px;
1832
+ }
1833
+
1830
1834
  [class*=" col-"], [class^="col-"] {
1831
1835
  float: left;
1832
1836
  min-height: 1rem;