@oat-sa/tao-core-ui 1.66.0 → 1.66.2

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.
@@ -97,14 +97,12 @@ const formCallbacks = ({ widget, formElement, mediaEditor, togglePlaceholder })
97
97
  const initForm = ({ widget, formElement, formTpl, mediaEditor, togglePlaceholder }) => {
98
98
  const imageElem = getImageElement(widget);
99
99
  const figcaptionElem = getCaptionElement(widget);
100
- const showFigure = widget.element.attr('showFigure');
101
100
  widget.$form.html(
102
101
  formTpl({
103
102
  baseUrl: widget.options.baseUrl || '',
104
103
  src: imageElem.attr('src'),
105
104
  alt: imageElem.attr('alt'),
106
- figcaption: figcaptionElem ? figcaptionElem.body() : '',
107
- showFigure: showFigure
105
+ figcaption: figcaptionElem ? figcaptionElem.body() : ''
108
106
  })
109
107
  );
110
108
 
@@ -127,15 +125,7 @@ const initForm = ({ widget, formElement, formTpl, mediaEditor, togglePlaceholder
127
125
  );
128
126
  };
129
127
 
130
- /**
131
- * @param {Object} stateFactory
132
- * @param {Object} ActiveState
133
- * @param {Object} formTpl
134
- * @param {Object} formElement
135
- * @param {Object} inlineHelper
136
- * @returns
137
- */
138
- export default function ({ stateFactory, ActiveState, formTpl, formElement, inlineHelper }) {
128
+ export default function (stateFactory, ActiveState, formTpl, formElement, inlineHelper) {
139
129
  /**
140
130
  * media Editor instance if has been initialized
141
131
  * @type {null}
@@ -144,7 +134,7 @@ export default function ({ stateFactory, ActiveState, formTpl, formElement, inli
144
134
  let textareaObserver = null;
145
135
  let texareaHTMLElem = null;
146
136
 
147
- const FigureStateActive = stateFactory.extend(
137
+ const ImgStateActive = stateFactory.extend(
148
138
  ActiveState,
149
139
  function () {
150
140
  this.initForm();
@@ -158,7 +148,7 @@ export default function ({ stateFactory, ActiveState, formTpl, formElement, inli
158
148
  }
159
149
  );
160
150
 
161
- FigureStateActive.prototype.initForm = function () {
151
+ ImgStateActive.prototype.initForm = function () {
162
152
  initForm({
163
153
  widget: this.widget,
164
154
  formElement,
@@ -180,5 +170,5 @@ export default function ({ stateFactory, ActiveState, formTpl, formElement, inli
180
170
  }
181
171
  };
182
172
 
183
- return FigureStateActive;
173
+ return ImgStateActive;
184
174
  }
@@ -15,34 +15,10 @@
15
15
  *
16
16
  * Copyright (c) 2021-2022 (original work) Open Assessment Technologies SA;
17
17
  */
18
- import _ from 'lodash';
19
18
 
20
19
  export const FLOAT_LEFT_CLASS = 'wrap-left';
21
20
  export const FLOAT_RIGHT_CLASS = 'wrap-right';
22
21
 
23
- const searchRecurse = (parentElement, serial) => {
24
- if (!parentElement) {
25
- return null;
26
- }
27
- if (parentElement.serial === serial) {
28
- return parentElement;
29
- }
30
- let found = null;
31
- _.some(parentElement['elements'], childElement => {
32
- if (childElement.serial === serial) {
33
- found = parentElement;
34
- } else if (childElement['elements']) {
35
- found = searchRecurse(childElement, serial);
36
- } else if (childElement['prompt']) {
37
- found = searchRecurse(childElement.prompt.bdy, serial);
38
- }
39
- if (found) {
40
- return true;
41
- }
42
- });
43
- return found;
44
- };
45
-
46
22
  export const positionFloat = function positionFloat(widget, position) {
47
23
  if (!position) {
48
24
  return;
@@ -67,36 +43,12 @@ export const positionFloat = function positionFloat(widget, position) {
67
43
  // Update DOM
68
44
  widget.$container.addClass(className);
69
45
  // Update model
70
- const prevClassName = widget.element.attr('class') || '';
71
46
  if (className) {
72
47
  widget.element.attr('class', className);
73
48
  } else {
74
49
  widget.element.removeAttr('class');
75
50
  }
76
51
 
77
- if (prevClassName !== className) {
78
- // Re-build Figure widget to toggle between inline/block
79
- const parent = searchRecurse(widget.element.bdy.rootElement.bdy, widget.serial);
80
- // avoid changes on Figure in a prompt
81
- if (parent.contentModel && parent.contentModel === 'inlineStatic') {
82
- _.defer(() => {
83
- widget.element.data('widget').refresh();
84
- });
85
- return;
86
- }
87
- widget.element.data('widget').changeState('sleep');
88
- _.defer(() => {
89
- if (parent && parent.data('widget')) {
90
- parent.data('widget').changeState('active');
91
- _.defer(() => {
92
- parent.data('widget').changeState('sleep');
93
- _.defer(() => {
94
- widget.element.data('widget').changeState('active');
95
- });
96
- });
97
- }
98
- });
99
- }
100
52
  widget.$original.trigger('contentChange.qti-widget');
101
53
  };
102
54
 
@@ -28,7 +28,7 @@ import 'select2';
28
28
  * Default config values
29
29
  * @type {Object}
30
30
  */
31
- var defaults = {
31
+ const defaults = {
32
32
  defaultSize: 25,
33
33
  options: [
34
34
  { label: '25 ' + __('items per page'), value: 25 },
@@ -47,15 +47,15 @@ var defaults = {
47
47
  * @param {Object} [config.items] - available options
48
48
  * @returns {pageSizeSelector}
49
49
  */
50
- var pageSizeSelectorFactory = function pageSizeSelectorFactory(config) {
51
- var pageSizeSelectorSpecs = {
52
- setSelectedOption: function setSelectedOption() {
53
- var options = this.config.options;
54
- var defaultSize = this.config.defaultSize;
50
+ export default function pageSizeSelectorFactory(config) {
51
+ const pageSizeSelectorSpecs = {
52
+ setSelectedOption() {
53
+ const options = this.config.options;
54
+ const defaultSize = parseInt(this.config.defaultSize, 10);
55
55
 
56
- var selectedOption;
57
- options.forEach(function (option) {
58
- if (option.value === defaultSize) {
56
+ let selectedOption;
57
+ options.forEach(option => {
58
+ if (parseInt(option.value, 10) === defaultSize) {
59
59
  selectedOption = option;
60
60
 
61
61
  option.selected = true;
@@ -73,34 +73,25 @@ var pageSizeSelectorFactory = function pageSizeSelectorFactory(config) {
73
73
 
74
74
  return component(pageSizeSelectorSpecs, defaults)
75
75
  .setTemplate(pageSizeSelectorTpl)
76
- .on('init', function () {
76
+ .on('init', function onInit() {
77
77
  this.setSelectedOption();
78
78
  })
79
- .on('render', function () {
80
- var self = this;
81
- var $component = this.getElement();
82
-
83
- $('.select2', $component)
79
+ .on('render', function onRender() {
80
+ $('.select2', this.getElement())
84
81
  .select2({
85
82
  dropdownCssClass: 'page-size-dropdown',
86
83
  minimumResultsForSearch: Infinity
87
84
  })
88
- .on('change', function (e) {
89
- self.trigger('change', e.val);
85
+ .on('change', e => {
86
+ this.trigger('change', e.val);
90
87
  });
91
88
  })
92
- .after('render', function () {
93
- var $component = this.getElement();
94
-
89
+ .after('render', function afterRender() {
95
90
  // Notify about the default value after render
96
- this.trigger('change', $('select', $component).val());
91
+ this.trigger('change', $('select', this.getElement()).val());
97
92
  })
98
- .on('destroy', function () {
99
- var $component = this.getElement();
100
-
101
- $('.select2', $component).select2('destroy');
93
+ .on('destroy', function onDestroy() {
94
+ $('.select2', this.getElement()).select2('destroy');
102
95
  })
103
96
  .init(config);
104
- };
105
-
106
- export default pageSizeSelectorFactory;
97
+ }
package/scss/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file