jclic 2.1.26 → 2.2.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.
@@ -109,7 +109,7 @@ export class FillInBlanksPanel extends TextActivityBasePanel {
109
109
  if (target.options[0].trim() !== '')
110
110
  $('<option selected/>', { value: '', text: '' }).appendTo($span);
111
111
  target.options.forEach(op => $('<option/>', { value: op, text: op }).appendTo($span));
112
- target.$comboList = $span.bind('focus change', event => {
112
+ target.$comboList = $span.on('focus change', event => {
113
113
  event.textTarget = target;
114
114
  this.processEvent(event);
115
115
  });
@@ -124,10 +124,10 @@ export class FillInBlanksPanel extends TextActivityBasePanel {
124
124
  id: idLabel,
125
125
  autocomplete: 'off',
126
126
  spellcheck: 'false'
127
- }).bind('focus input blur', event => {
127
+ }).on('focus input blur', event => {
128
128
  event.textTarget = target;
129
129
  this.processEvent(event);
130
- }).bind('keydown keyup', event => {
130
+ }).on('keydown keyup', event => {
131
131
  // Catch `enter` key in Firefox
132
132
  if (event.keyCode === 13) {
133
133
  event.preventDefault();
@@ -204,10 +204,10 @@ export class FillInBlanksPanel extends TextActivityBasePanel {
204
204
 
205
205
  const destTarget = this.targets[p];
206
206
  if (destTarget.$span) {
207
- destTarget.$span.focus();
207
+ destTarget.$span.trigger('focus');
208
208
  setSelectionRange(destTarget.$span.get(-1), 0, 0);
209
209
  } else if (destTarget.$comboList)
210
- destTarget.$comboList.focus();
210
+ destTarget.$comboList.trigger('focus');
211
211
  }
212
212
  return ok;
213
213
  }
@@ -283,7 +283,7 @@ export class FillInBlanksPanel extends TextActivityBasePanel {
283
283
  // `pre-wrap` (needed for tabulated texts)
284
284
  $('.JClicTextTarget').css('white-space', 'normal');
285
285
  if (this.targets.length > 0 && this.targets[0].$span)
286
- this.targets[0].$span.focus();
286
+ this.targets[0].$span.trigger('focus');
287
287
  }
288
288
 
289
289
  /**
@@ -294,9 +294,9 @@ export class FillInBlanksPanel extends TextActivityBasePanel {
294
294
  finishActivity(result) {
295
295
  this.targets.forEach(target => {
296
296
  if (target.$span)
297
- target.$span.removeAttr('contenteditable').blur();
297
+ target.$span.removeAttr('contenteditable').trigger('blur');
298
298
  else if (target.$comboList)
299
- target.$comboList.attr('disabled', 'true').blur();
299
+ target.$comboList.prop('disabled', true).trigger('blur');
300
300
  });
301
301
  return super.finishActivity(result);
302
302
  }
@@ -77,7 +77,7 @@ class IdentifyTextPanel extends TextActivityBasePanel {
77
77
  $createTargetElement(target, $span) {
78
78
  super.$createTargetElement(target, $span);
79
79
  const idLabel = `target${`000${this.targets.length - 1}`.slice(-3)}`;
80
- $span.bind('click', event => {
80
+ $span.on('click', event => {
81
81
  event.textTarget = target;
82
82
  event.idLabel = idLabel;
83
83
  this.processEvent(event);
@@ -86,7 +86,7 @@ class IdentifyTextPanel extends TextActivityBasePanel {
86
86
  }
87
87
 
88
88
  $createSpanElement($span) {
89
- $span.bind('click', event => {
89
+ $span.on('click', event => {
90
90
  event.$spanElement = $span;
91
91
  this.processEvent(event);
92
92
  });
@@ -155,7 +155,7 @@ export class OrderTextPanel extends TextActivityBasePanel {
155
155
  $createTargetElement(target, $span) {
156
156
  super.$createTargetElement(target, $span);
157
157
  const idLabel = `target${`000${this.targets.length - 1}`.slice(-3)}`;
158
- $span.addClass('JClicTextTarget').bind('click', event => {
158
+ $span.addClass('JClicTextTarget').on('click', event => {
159
159
  event.textTarget = target;
160
160
  event.idLabel = idLabel;
161
161
  this.processEvent(event);
@@ -264,7 +264,7 @@ export class TextActivityBasePanel extends ActivityPanel {
264
264
 
265
265
  // Catch on-demand popups with `F1`, cancel with `Escape`
266
266
  if ($popup !== null && target.infoMode === 'onDemand') {
267
- $span.keydown(ev => {
267
+ $span.on('keydown', ev => {
268
268
  if (ev.key === target.popupKey) {
269
269
  ev.preventDefault();
270
270
  this.showPopup($popup, target.popupMaxTime, target.popupDelay);
@@ -374,7 +374,7 @@ export class TextActivityBasePanel extends ActivityPanel {
374
374
 
375
375
  const prevScreenEnd = () => {
376
376
  this.showingPrevScreen = false;
377
- this.$div.unbind('click');
377
+ this.$div.off('click');
378
378
  if (this.prevScreenTimer) {
379
379
  window.clearTimeout(this.prevScreenTimer);
380
380
  this.prevScreenTimer = null;
@@ -432,7 +432,7 @@ export class TextActivityBasePanel extends ActivityPanel {
432
432
  this.$checkButton.prop('disabled', true);
433
433
  this.targets.forEach(t => {
434
434
  if (t.$comboList)
435
- t.$comboList.attr('disabled', true);
435
+ t.$comboList.prop('disabled', true);
436
436
  });
437
437
  this.showPopup(null);
438
438
  super.finishActivity(result);
@@ -29,6 +29,8 @@
29
29
  * @module
30
30
  */
31
31
 
32
+ /* global structuredClone */
33
+
32
34
  import $ from 'jquery';
33
35
  import { log, attrForEach, checkColor, getBoolean, getAttr, setAttr, getVal, getNumber, settings } from '../../Utils.js';
34
36
  import ActiveBoxContent from '../../boxes/ActiveBoxContent.js';
@@ -46,7 +48,7 @@ export class TextActivityDocument {
46
48
  */
47
49
  constructor() {
48
50
  // Make a deep clone of the default style
49
- this.style = { 'default': { ...TextActivityDocument.DEFAULT_DOC_STYLE } };
51
+ this.style = { 'default': structuredClone(TextActivityDocument.DEFAULT_DOC_STYLE) };
50
52
  this.p = [];
51
53
  }
52
54
 
@@ -464,7 +464,7 @@ export class WrittenAnswerPanel extends ActivityPanel {
464
464
  if (bx)
465
465
  this.currentCell = bx.idLoc;
466
466
  this.$textField.val('');
467
- this.$textField.focus();
467
+ this.$textField.trigger('focus');
468
468
  this.invalidate().update();
469
469
  if (bx)
470
470
  bx.playMedia(this.ps, delayedActions);
@@ -491,7 +491,7 @@ export class WrittenAnswerPanel extends ActivityPanel {
491
491
 
492
492
  // Avoid clicks on the text field
493
493
  if (this.bgB.contains(p)) {
494
- this.$textField.focus();
494
+ this.$textField.trigger('focus');
495
495
  break;
496
496
  }
497
497
 
@@ -154,7 +154,7 @@ export class CrossWordPanel extends ActivityPanel {
154
154
  'background-image': `url(${type === 'acrossClues' ? this.hIcon : this.vIcon})`,
155
155
  'background-repeat': 'no-repeat',
156
156
  'background-position': 'center',
157
- 'border-radius': 6,
157
+ 'border-radius': '6px',
158
158
  'z-index': 10
159
159
  }).on('click', () => {
160
160
  this.advance = type === 'acrossClues' ?
@@ -247,7 +247,7 @@ export class CrossWordPanel extends ActivityPanel {
247
247
  this.setAndPlayMsg('initial', 'start');
248
248
  this.invalidate().update();
249
249
  this.$div.attr("tabindex", 0);
250
- this.$div.focus();
250
+ this.$div.trigger('focus');
251
251
  this.playing = true;
252
252
  }
253
253
  }
@@ -723,9 +723,9 @@ export class ActiveBox extends AbstractBox {
723
723
  disabled = this.isInactive() && !this.accessibleAlwaysActive;
724
724
  this.$accessibleElement = $('<button/>', {
725
725
  tabindex: disabled ? -1 : 0,
726
- id: `AE${id}`,
727
- disabled: disabled
726
+ id: `AE${id}`
728
727
  })
728
+ .prop('disabled', disabled ? true : null)
729
729
  .html(this.toString())
730
730
  .on('click', ev => {
731
731
  // Check if event was produced by a mouse click
package/src/skins/Skin.js CHANGED
@@ -735,10 +735,8 @@ export class Skin extends Container {
735
735
  * @param {boolean} enabled
736
736
  */
737
737
  setEnabled($object, enabled) {
738
- if ($object && enabled)
739
- $object.removeAttr('disabled');
740
- else if ($object)
741
- $object.attr('disabled', true);
738
+ if ($object)
739
+ $object.prop('disabled', enabled ? null : true);
742
740
  }
743
741
 
744
742
  /**