jclic 2.2.0 → 2.3.0
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.
- package/README.md +5 -7
- package/dist-node/jclic-node.js +14157 -0
- package/dist-node/jclic-node.umd.cjs +530 -0
- package/package.json +38 -26
- package/.vscode/launch.json +0 -33
- package/.vscode/settings.json +0 -13
- package/CHANGELOG.md +0 -664
- package/TRANSLATIONS.md +0 -11
- package/build-locales.mjs +0 -82
- package/dist/jclic-node.js +0 -31678
- package/dist/jclic-node.js.map +0 -1
- package/dist/jclic.components.LICENSE +0 -2254
- package/dist/jclic.min.js +0 -27
- package/dist/jclic.min.js.map +0 -1
- package/eslint.config.mjs +0 -31
- package/jsdoc.config.js +0 -71
- package/locales/ar.po +0 -244
- package/locales/ast.po +0 -246
- package/locales/bs.po +0 -247
- package/locales/ca.po +0 -248
- package/locales/ca_ES@valencia.po +0 -248
- package/locales/cs.po +0 -244
- package/locales/da.po +0 -244
- package/locales/de.po +0 -246
- package/locales/el.po +0 -244
- package/locales/es.po +0 -248
- package/locales/eu.po +0 -244
- package/locales/fr.po +0 -244
- package/locales/gl.po +0 -244
- package/locales/he.po +0 -244
- package/locales/hr.po +0 -245
- package/locales/it.po +0 -246
- package/locales/ja.po +0 -242
- package/locales/jclic.js.pot +0 -241
- package/locales/nb_NO.po +0 -244
- package/locales/nl.po +0 -244
- package/locales/pl.po +0 -244
- package/locales/pt.po +0 -244
- package/locales/pt_BR.po +0 -248
- package/locales/ro.po +0 -248
- package/locales/ru.po +0 -245
- package/locales/ta.po +0 -244
- package/locales/tr.po +0 -246
- package/locales/uk.po +0 -247
- package/locales/vec.po +0 -244
- package/locales/zh_TW.po +0 -246
- package/patches/po2json+1.0.0-beta-3.patch +0 -12
- package/src/AWT.js +0 -2067
- package/src/Activity.js +0 -1311
- package/src/Deps.js +0 -232
- package/src/GlobalData.js +0 -5
- package/src/JClic.js +0 -196
- package/src/JClicPlayer.js +0 -1308
- package/src/PlayerHistory.js +0 -305
- package/src/Utils.js +0 -1355
- package/src/activities/associations/ComplexAssociation.js +0 -321
- package/src/activities/associations/SimpleAssociation.js +0 -519
- package/src/activities/memory/MemoryGame.js +0 -423
- package/src/activities/panels/Explore.js +0 -349
- package/src/activities/panels/Identify.js +0 -356
- package/src/activities/panels/InformationScreen.js +0 -262
- package/src/activities/panels/Menu.js +0 -209
- package/src/activities/panels/icons/ico00.png +0 -0
- package/src/activities/panels/icons/ico01.png +0 -0
- package/src/activities/panels/icons/ico02.png +0 -0
- package/src/activities/panels/icons/ico03.png +0 -0
- package/src/activities/panels/icons/icofolder.png +0 -0
- package/src/activities/puzzles/DoublePuzzle.js +0 -424
- package/src/activities/puzzles/ExchangePuzzle.js +0 -374
- package/src/activities/puzzles/HolePuzzle.js +0 -360
- package/src/activities/text/Complete.js +0 -127
- package/src/activities/text/Evaluator.js +0 -534
- package/src/activities/text/FillInBlanks.js +0 -426
- package/src/activities/text/IdentifyText.js +0 -253
- package/src/activities/text/OrderText.js +0 -421
- package/src/activities/text/TextActivityBase.js +0 -557
- package/src/activities/text/TextActivityDocument.js +0 -658
- package/src/activities/text/WrittenAnswer.js +0 -557
- package/src/activities/textGrid/CrossWord.js +0 -565
- package/src/activities/textGrid/WordSearch.js +0 -458
- package/src/activities/textGrid/icons/hIcon.svg +0 -3
- package/src/activities/textGrid/icons/vIcon.svg +0 -3
- package/src/automation/AutoContentProvider.js +0 -182
- package/src/automation/arith/Arith.js +0 -864
- package/src/bags/ActivitySequence.js +0 -318
- package/src/bags/ActivitySequenceElement.js +0 -161
- package/src/bags/ActivitySequenceJump.js +0 -140
- package/src/bags/ConditionalJumpInfo.js +0 -113
- package/src/bags/JumpInfo.js +0 -136
- package/src/bags/MediaBag.js +0 -215
- package/src/bags/MediaBagElement.js +0 -516
- package/src/boxes/AbstractBox.js +0 -699
- package/src/boxes/ActiveBagContent.js +0 -494
- package/src/boxes/ActiveBox.js +0 -810
- package/src/boxes/ActiveBoxBag.js +0 -357
- package/src/boxes/ActiveBoxContent.js +0 -484
- package/src/boxes/ActiveBoxGrid.js +0 -179
- package/src/boxes/BoxBag.js +0 -500
- package/src/boxes/BoxBase.js +0 -398
- package/src/boxes/BoxConnector.js +0 -325
- package/src/boxes/TextGrid.js +0 -887
- package/src/boxes/TextGridContent.js +0 -215
- package/src/init-jsdom.js +0 -65
- package/src/jclic-node.js +0 -219
- package/src/media/ActiveMediaBag.js +0 -145
- package/src/media/ActiveMediaPlayer.js +0 -297
- package/src/media/AudioBuffer.js +0 -219
- package/src/media/EventSounds.js +0 -169
- package/src/media/EventSoundsElement.js +0 -155
- package/src/media/MediaContent.js +0 -328
- package/src/media/MidiAudioPlayer.js +0 -254
- package/src/media/icons/audio.svg +0 -3
- package/src/media/icons/generic.svg +0 -3
- package/src/media/icons/mic.svg +0 -3
- package/src/media/icons/movie.svg +0 -3
- package/src/media/icons/music.svg +0 -3
- package/src/media/icons/url.svg +0 -3
- package/src/media/sounds/actionError.mp3 +0 -0
- package/src/media/sounds/actionOk.mp3 +0 -0
- package/src/media/sounds/click.mp3 +0 -0
- package/src/media/sounds/finishedError.mp3 +0 -0
- package/src/media/sounds/finishedOk.mp3 +0 -0
- package/src/media/sounds/start.mp3 +0 -0
- package/src/project/JClicProject.js +0 -282
- package/src/project/ProjectSettings.js +0 -273
- package/src/report/ActionReg.js +0 -123
- package/src/report/ActivityReg.js +0 -271
- package/src/report/EncryptMin.js +0 -210
- package/src/report/Reporter.js +0 -727
- package/src/report/SCORM.js +0 -272
- package/src/report/SequenceReg.js +0 -275
- package/src/report/SessionReg.js +0 -340
- package/src/report/SessionStorageReporter.js +0 -131
- package/src/report/TCPReporter.js +0 -628
- package/src/shapers/ClassicJigSaw.js +0 -138
- package/src/shapers/Holes.js +0 -77
- package/src/shapers/JigSaw.js +0 -161
- package/src/shapers/Rectangular.js +0 -78
- package/src/shapers/Shaper.js +0 -386
- package/src/shapers/TriangularJigSaw.js +0 -121
- package/src/skins/BlueSkin.js +0 -80
- package/src/skins/Counter.js +0 -152
- package/src/skins/CustomSkin.js +0 -412
- package/src/skins/DefaultSkin.js +0 -376
- package/src/skins/EmptySkin.js +0 -82
- package/src/skins/GreenSkin.js +0 -94
- package/src/skins/MiniSkin.js +0 -130
- package/src/skins/OrangeSkin.js +0 -78
- package/src/skins/SimpleSkin.js +0 -92
- package/src/skins/Skin.js +0 -1021
- package/src/skins/assets/actionsIcon.svg +0 -3
- package/src/skins/assets/appLogo.svg +0 -8
- package/src/skins/assets/basic.css +0 -41
- package/src/skins/assets/closeDialogIcon.svg +0 -3
- package/src/skins/assets/closeIcon.svg +0 -3
- package/src/skins/assets/copyIcon.svg +0 -3
- package/src/skins/assets/fullScreenExitIcon.svg +0 -3
- package/src/skins/assets/fullScreenIcon.svg +0 -3
- package/src/skins/assets/infoIcon.svg +0 -3
- package/src/skins/assets/main.css +0 -43
- package/src/skins/assets/mainHalf.css +0 -23
- package/src/skins/assets/mainTwoThirds.css +0 -23
- package/src/skins/assets/mini.css +0 -15
- package/src/skins/assets/nextIcon.svg +0 -3
- package/src/skins/assets/okDialogIcon.svg +0 -3
- package/src/skins/assets/prevIcon.svg +0 -3
- package/src/skins/assets/reports.css +0 -156
- package/src/skins/assets/reportsIcon.svg +0 -3
- package/src/skins/assets/scoreIcon.svg +0 -3
- package/src/skins/assets/simple.css +0 -16
- package/src/skins/assets/simpleHalf.css +0 -11
- package/src/skins/assets/simpleTwoThirds.css +0 -11
- package/src/skins/assets/timeIcon.svg +0 -4
- package/src/skins/assets/waitAnim.css +0 -54
- package/src/skins/assets/waitImgBig.svg +0 -3
- package/src/skins/assets/waitImgSmall.svg +0 -3
- package/webpack.config.mjs +0 -169
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : activities/panels/InformationScreen.js
|
|
3
|
-
* Created : 19/05/2015
|
|
4
|
-
* By : Francesc Busquets <francesc@gmail.com>
|
|
5
|
-
*
|
|
6
|
-
* JClic.js
|
|
7
|
-
* An HTML5 player of JClic activities
|
|
8
|
-
* https://projectestac.github.io/jclic.js
|
|
9
|
-
*
|
|
10
|
-
* @source https://github.com/projectestac/jclic.js
|
|
11
|
-
*
|
|
12
|
-
* @license EUPL-1.2
|
|
13
|
-
* @licstart
|
|
14
|
-
* (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
|
|
15
|
-
*
|
|
16
|
-
* Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
|
|
17
|
-
* the European Commission- subsequent versions of the EUPL (the "Licence");
|
|
18
|
-
* You may not use this work except in compliance with the Licence.
|
|
19
|
-
*
|
|
20
|
-
* You may obtain a copy of the Licence at:
|
|
21
|
-
* https://joinup.ec.europa.eu/software/page/eupl
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
-
* distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
|
|
25
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
26
|
-
* Licence for the specific language governing permissions and limitations
|
|
27
|
-
* under the Licence.
|
|
28
|
-
* @licend
|
|
29
|
-
* @module
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/* global window */
|
|
33
|
-
|
|
34
|
-
import $ from 'jquery';
|
|
35
|
-
import { Activity, ActivityPanel } from '../../Activity.js';
|
|
36
|
-
import ActiveBoxGrid from '../../boxes/ActiveBoxGrid.js';
|
|
37
|
-
import BoxBag from '../../boxes/BoxBag.js';
|
|
38
|
-
import { Rectangle, Point } from '../../AWT.js';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* This class of {@link module:Activity.Activity Activity} just shows a panel with {@link module:boxes/ActiveBox.ActiveBox ActiveBox} objects.
|
|
42
|
-
* Because active boxes can act as a links to specific points in the project's sequence of
|
|
43
|
-
* activities, this kind of activity is often used as a menu where users can choose from different
|
|
44
|
-
* options.
|
|
45
|
-
* @extends module:Activity.Activity
|
|
46
|
-
*/
|
|
47
|
-
export class InformationScreen extends Activity {
|
|
48
|
-
/**
|
|
49
|
-
* InformationScreen constructor
|
|
50
|
-
* @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
|
|
51
|
-
*/
|
|
52
|
-
constructor(project) {
|
|
53
|
-
super(project);
|
|
54
|
-
// This kind of activities are not reported
|
|
55
|
-
this.includeInReports = false;
|
|
56
|
-
this.reportActions = false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* The {@link module:Activity.ActivityPanel ActivityPanel} where {@link module:activities/panels/InformationScreen.InformationScreen InformationScreen} activities should display its content
|
|
62
|
-
* @extends module:Activity.ActivityPanel
|
|
63
|
-
*/
|
|
64
|
-
export class InformationScreenPanel extends ActivityPanel {
|
|
65
|
-
/**
|
|
66
|
-
* InformationScreenPanel constructor
|
|
67
|
-
* @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
|
|
68
|
-
* @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
|
|
69
|
-
* [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
|
|
70
|
-
* @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
|
|
71
|
-
*/
|
|
72
|
-
constructor(act, ps, $div) {
|
|
73
|
-
super(act, ps, $div);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Miscellaneous cleaning operations
|
|
78
|
-
* @override
|
|
79
|
-
*/
|
|
80
|
-
clear() {
|
|
81
|
-
if (this.bg) {
|
|
82
|
-
this.bg.end();
|
|
83
|
-
this.bg = null;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Prepares the visual components of the activity
|
|
89
|
-
* @override
|
|
90
|
-
*/
|
|
91
|
-
buildVisualComponents() {
|
|
92
|
-
if (this.firstRun)
|
|
93
|
-
super.buildVisualComponents();
|
|
94
|
-
this.clear();
|
|
95
|
-
const abc = this.act.abc['primary'];
|
|
96
|
-
if (abc) {
|
|
97
|
-
if (abc.image) {
|
|
98
|
-
abc.setImgContent(this.act.project.mediaBag, null, false);
|
|
99
|
-
if (abc.animatedGifFile && !abc.shaper.rectangularShapes)
|
|
100
|
-
this.$animatedBg = $('<span/>').css({
|
|
101
|
-
'background-image': `url(${abc.animatedGifFile})`,
|
|
102
|
-
'background-position': 'center',
|
|
103
|
-
'background-repeat': 'no-repeat',
|
|
104
|
-
position: 'absolute'
|
|
105
|
-
}).appendTo(this.$div);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (this.act.acp !== null)
|
|
109
|
-
this.act.acp.generateContent(abc.nch, abc.ncw, [abc], false);
|
|
110
|
-
|
|
111
|
-
this.bg = ActiveBoxGrid.createEmptyGrid(null, this,
|
|
112
|
-
this.act.margin, this.act.margin,
|
|
113
|
-
abc);
|
|
114
|
-
this.bg.setContent(abc);
|
|
115
|
-
if (this.$animatedBg)
|
|
116
|
-
this.bg.setCellAttr('tmpTrans', true);
|
|
117
|
-
this.bg.setVisible(true);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Basic initialization procedure
|
|
123
|
-
* @override
|
|
124
|
-
*/
|
|
125
|
-
initActivity() {
|
|
126
|
-
super.initActivity();
|
|
127
|
-
if (!this.firstRun)
|
|
128
|
-
this.buildVisualComponents();
|
|
129
|
-
else
|
|
130
|
-
this.firstRun = false;
|
|
131
|
-
|
|
132
|
-
this.invalidate().update();
|
|
133
|
-
this.setAndPlayMsg('initial', 'start');
|
|
134
|
-
this.playing = true;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Updates the graphic content of this panel.
|
|
139
|
-
* This method will be called from {@link module:AWT.Container#update} when needed.
|
|
140
|
-
* @override
|
|
141
|
-
* @param {module:AWT.Rectangle} dirtyRegion - Specifies the area to be updated. When `null`,
|
|
142
|
-
* it's the whole panel.
|
|
143
|
-
*/
|
|
144
|
-
updateContent(dirtyRegion) {
|
|
145
|
-
super.updateContent(dirtyRegion);
|
|
146
|
-
if (this.bg && this.$canvas) {
|
|
147
|
-
const
|
|
148
|
-
canvas = this.$canvas.get(-1),
|
|
149
|
-
ctx = canvas.getContext('2d');
|
|
150
|
-
if (!dirtyRegion)
|
|
151
|
-
dirtyRegion = new Rectangle(0, 0, canvas.width, canvas.height);
|
|
152
|
-
ctx.clearRect(dirtyRegion.pos.x, dirtyRegion.pos.y, dirtyRegion.dim.width, dirtyRegion.dim.height);
|
|
153
|
-
this.bg.update(ctx, dirtyRegion);
|
|
154
|
-
}
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Sets the real dimension of this panel.
|
|
160
|
-
* @override
|
|
161
|
-
* @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
|
|
162
|
-
* @returns {module:AWT.Dimension}
|
|
163
|
-
*/
|
|
164
|
-
setDimension(preferredMaxSize) {
|
|
165
|
-
return this.getBounds().equals(preferredMaxSize) ?
|
|
166
|
-
preferredMaxSize :
|
|
167
|
-
BoxBag.layoutSingle(preferredMaxSize, this.bg, this.act.margin);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
/**
|
|
171
|
-
* Sets the size and position of this activity panel
|
|
172
|
-
* @override
|
|
173
|
-
* @param {module:AWT.Rectangle} rect
|
|
174
|
-
*/
|
|
175
|
-
setBounds(rect) {
|
|
176
|
-
if (this.$canvas)
|
|
177
|
-
this.$canvas.remove();
|
|
178
|
-
|
|
179
|
-
super.setBounds(rect);
|
|
180
|
-
if (this.bg) {
|
|
181
|
-
this.$canvas = $('<canvas width="' + rect.dim.width + '" height="' + rect.dim.height + '"/>').css({
|
|
182
|
-
position: 'absolute',
|
|
183
|
-
top: 0,
|
|
184
|
-
left: 0
|
|
185
|
-
});
|
|
186
|
-
// Resize animated gif background
|
|
187
|
-
if (this.$animatedBg) {
|
|
188
|
-
const bgRect = this.bg.getBounds();
|
|
189
|
-
this.$animatedBg.css({
|
|
190
|
-
left: bgRect.pos.x,
|
|
191
|
-
top: bgRect.pos.y,
|
|
192
|
-
width: `${bgRect.dim.width}px`,
|
|
193
|
-
height: `${bgRect.dim.height}px`,
|
|
194
|
-
'background-size': `${bgRect.dim.width}px ${bgRect.dim.height}px`
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
this.$div.append(this.$canvas);
|
|
198
|
-
this.invalidate().update();
|
|
199
|
-
window.setTimeout(() => this.bg ? this.bg.buildAccessibleElements(this.$canvas, this.$div) : null, 0);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Builds the accessible components needed for this ActivityPanel
|
|
205
|
-
* This method is called when all main elements are placed and visible, when the activity is ready
|
|
206
|
-
* to start or when resized.
|
|
207
|
-
* @override
|
|
208
|
-
*/
|
|
209
|
-
buildAccessibleComponents() {
|
|
210
|
-
if (this.$canvas && this.accessibleCanvas && this.bg) {
|
|
211
|
-
super.buildAccessibleComponents();
|
|
212
|
-
this.bg.buildAccessibleElements(this.$canvas, this.$div);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
/**
|
|
217
|
-
* Main handler used to process mouse, touch, keyboard and edit events
|
|
218
|
-
* @override
|
|
219
|
-
* @param {external:Event} event - The HTML event to be processed
|
|
220
|
-
* @returns {boolean} - When this event handler returns `false`, jQuery will stop its
|
|
221
|
-
* propagation through the DOM tree. See: {@link http://api.jquery.com/on}
|
|
222
|
-
*/
|
|
223
|
-
processEvent(event) {
|
|
224
|
-
if (this.playing) {
|
|
225
|
-
const p = new Point(
|
|
226
|
-
event.pageX - this.$div.offset().left,
|
|
227
|
-
event.pageY - this.$div.offset().top);
|
|
228
|
-
// Array to be filled with actions to be executed at the end of event processing
|
|
229
|
-
const delayedActions = [];
|
|
230
|
-
this.ps.stopMedia(1);
|
|
231
|
-
const bx = this.bg.findActiveBox(p);
|
|
232
|
-
if (bx) {
|
|
233
|
-
if (!bx.playMedia(this.ps, delayedActions))
|
|
234
|
-
this.playEvent('click');
|
|
235
|
-
}
|
|
236
|
-
delayedActions.forEach(action => action());
|
|
237
|
-
event.preventDefault();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
Object.assign(InformationScreenPanel.prototype, {
|
|
243
|
-
/**
|
|
244
|
-
* The {@link module:boxes/ActiveBoxbag.ActiveBoxBag ActiveBoxBag} containing the information to be displayed.
|
|
245
|
-
* @name module:activities/panels/InformationScreen.InformationScreenPanel#bg
|
|
246
|
-
* @type {module:boxes/ActiveBoxBag.ActiveBoxBag} */
|
|
247
|
-
bg: null,
|
|
248
|
-
/**
|
|
249
|
-
* List of mouse, touch and keyboard events intercepted by this panel
|
|
250
|
-
* @override
|
|
251
|
-
* @name module:activities/panels/InformationScreen.InformationScreenPanel#events
|
|
252
|
-
* @type {string[]} */
|
|
253
|
-
events: ['click'],
|
|
254
|
-
});
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Panel class associated to this type of activity: {@link module:activities/panels/InformationScreen.InformationScreenPanel InformationScreenPanel}
|
|
258
|
-
* @type {class} */
|
|
259
|
-
InformationScreen.Panel = InformationScreenPanel;
|
|
260
|
-
|
|
261
|
-
// Register activity class
|
|
262
|
-
export default Activity.registerClass('@panels.InformationScreen', InformationScreen);
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* File : activities/panels/Menu.js
|
|
3
|
-
* Created : 20/07/2017
|
|
4
|
-
* By : Francesc Busquets <francesc@gmail.com>
|
|
5
|
-
*
|
|
6
|
-
* JClic.js
|
|
7
|
-
* An HTML5 player of JClic activities
|
|
8
|
-
* https://projectestac.github.io/jclic.js
|
|
9
|
-
*
|
|
10
|
-
* @source https://github.com/projectestac/jclic.js
|
|
11
|
-
*
|
|
12
|
-
* @license EUPL-1.2
|
|
13
|
-
* @licstart
|
|
14
|
-
* (c) 2000-2020 Educational Telematic Network of Catalonia (XTEC)
|
|
15
|
-
*
|
|
16
|
-
* Licensed under the EUPL, Version 1.1 or -as soon they will be approved by
|
|
17
|
-
* the European Commission- subsequent versions of the EUPL (the "Licence");
|
|
18
|
-
* You may not use this work except in compliance with the Licence.
|
|
19
|
-
*
|
|
20
|
-
* You may obtain a copy of the Licence at:
|
|
21
|
-
* https://joinup.ec.europa.eu/software/page/eupl
|
|
22
|
-
*
|
|
23
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
24
|
-
* distributed under the Licence is distributed on an "AS IS" basis, WITHOUT
|
|
25
|
-
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
26
|
-
* Licence for the specific language governing permissions and limitations
|
|
27
|
-
* under the Licence.
|
|
28
|
-
* @licend
|
|
29
|
-
* @module
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
import $ from 'jquery';
|
|
33
|
-
import { Activity, ActivityPanel } from '../../Activity.js';
|
|
34
|
-
import MediaContent from '../../media/MediaContent.js';
|
|
35
|
-
import { log } from '../../Utils.js';
|
|
36
|
-
|
|
37
|
-
// Use Webpack to import PNG files
|
|
38
|
-
import ico00 from './icons/ico00.png';
|
|
39
|
-
import ico01 from './icons/ico01.png';
|
|
40
|
-
import ico02 from './icons/ico02.png';
|
|
41
|
-
import ico03 from './icons/ico03.png';
|
|
42
|
-
import icoFolder from './icons/icofolder.png';
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* This class of {@link module:Activity.Activity Activity} is only used in legacy JClic project libraries. It contains
|
|
46
|
-
* one or more buttons pointing to specific JClic projects or to other `Menu` activity panels.
|
|
47
|
-
* @extends module:Activity.Activity
|
|
48
|
-
*/
|
|
49
|
-
export class Menu extends Activity {
|
|
50
|
-
/**
|
|
51
|
-
* Menu constructor
|
|
52
|
-
* @param {module:project/JClicProject.JClicProject} project - The {@link module:project/JClicProject.JClicProject JClicProject} to which this activity belongs
|
|
53
|
-
*/
|
|
54
|
-
constructor(project) {
|
|
55
|
-
super(project);
|
|
56
|
-
this.menuElements = [];
|
|
57
|
-
// This kind of activities are not reported
|
|
58
|
-
this.includeInReports = false;
|
|
59
|
-
this.reportActions = false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* The {@link module:Activity.ActivityPanel ActivityPanel} where Menu will show its content.
|
|
65
|
-
* @extends module:Activity.ActivityPanel
|
|
66
|
-
*/
|
|
67
|
-
export class MenuPanel extends ActivityPanel {
|
|
68
|
-
/**
|
|
69
|
-
* MenuPanel constructor
|
|
70
|
-
* @param {module:Activity.Activity} act - The {@link module:Activity.Activity Activity} to which this Panel belongs
|
|
71
|
-
* @param {module:JClicPlayer.JClicPlayer} ps - Any object implementing the methods defined in the
|
|
72
|
-
* [PlayStation](http://projectestac.github.io/jclic/apidoc/edu/xtec/jclic/PlayStation.html) Java interface.
|
|
73
|
-
* @param {external:jQuery} [$div] - The jQuery DOM element where this Panel will deploy
|
|
74
|
-
*/
|
|
75
|
-
constructor(act, ps, $div) {
|
|
76
|
-
super(act, ps, $div);
|
|
77
|
-
// This kind of activity will always clean the "last project skin" setting
|
|
78
|
-
ps.lastProjectSkin = null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Prepares the visual components of the activity
|
|
83
|
-
* @override
|
|
84
|
-
*/
|
|
85
|
-
buildVisualComponents() {
|
|
86
|
-
if (this.firstRun)
|
|
87
|
-
super.buildVisualComponents();
|
|
88
|
-
// This `div` will contain the action buttons
|
|
89
|
-
const $btnDiv = $('<div/>').css({
|
|
90
|
-
'width': '100%',
|
|
91
|
-
'max-height': '100%',
|
|
92
|
-
'position': 'absolute',
|
|
93
|
-
'top': '50%',
|
|
94
|
-
'transform': 'translateY(-50%)',
|
|
95
|
-
'display': 'flex',
|
|
96
|
-
'flex-wrap': 'wrap',
|
|
97
|
-
'overflow-y': 'auto',
|
|
98
|
-
'place-content': 'center',
|
|
99
|
-
'overflow-y': 'auto'
|
|
100
|
-
});
|
|
101
|
-
this.act.menuElements.forEach((me) => {
|
|
102
|
-
// Create a button for each menu element
|
|
103
|
-
const caption = me.description || me.caption || 'JClic';
|
|
104
|
-
const $btn = $('<button/>', {
|
|
105
|
-
class: 'StockBtn',
|
|
106
|
-
title: caption,
|
|
107
|
-
'aria-label': caption
|
|
108
|
-
}).css({
|
|
109
|
-
'min-width': '80px',
|
|
110
|
-
'max-width': '200px',
|
|
111
|
-
'min-height': '80px',
|
|
112
|
-
'margin': '4px',
|
|
113
|
-
'padding': '4px',
|
|
114
|
-
'display': 'flex',
|
|
115
|
-
'flex-direction': 'column',
|
|
116
|
-
'justify-content': 'center',
|
|
117
|
-
'align-items': 'center'
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// Set the button icon
|
|
121
|
-
const
|
|
122
|
-
iconSrc = MenuPanel.icons[me.icon || '@ico00.png'],
|
|
123
|
-
$img = $('<img/>', { src: iconSrc || '' }).css({
|
|
124
|
-
'max-width': '180px',
|
|
125
|
-
'max-height': '100px',
|
|
126
|
-
'margin': '4px'
|
|
127
|
-
});
|
|
128
|
-
if (!iconSrc) {
|
|
129
|
-
// It's not a stock image, so load `src` when available
|
|
130
|
-
const mbe = this.act.project.mediaBag.getElement(me.icon, true);
|
|
131
|
-
mbe.getFullPathPromise().then(imgFullPath => $img.attr('src', imgFullPath));
|
|
132
|
-
}
|
|
133
|
-
$btn.append($img);
|
|
134
|
-
|
|
135
|
-
// Set the button text
|
|
136
|
-
$btn.append($('<span/>').css({
|
|
137
|
-
'max-width': '180px',
|
|
138
|
-
'overflow': 'hidden',
|
|
139
|
-
'white-space': 'nowrap',
|
|
140
|
-
'text-overflow': 'ellipsis'
|
|
141
|
-
}).html(me.caption));
|
|
142
|
-
|
|
143
|
-
// Set a click listener method
|
|
144
|
-
// $btn.on('click', function...) does not work!
|
|
145
|
-
$btn[0].addEventListener('click', (ev) => {
|
|
146
|
-
const mc = new MediaContent(me.projectPath ? 'RUN_CLIC_PACKAGE' : 'RUN_CLIC_ACTIVITY', me.sequence);
|
|
147
|
-
if (me.projectPath)
|
|
148
|
-
mc.externalParam = me.projectPath;
|
|
149
|
-
log('info', `Launching ${me.projectPath || ''} ${me.sequence || ''}`);
|
|
150
|
-
this.ps.playMedia(mc);
|
|
151
|
-
ev.preventDefault();
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// Place the created button on the container
|
|
155
|
-
$btnDiv.append($btn);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
// Add the buttons container on the main panel `div`
|
|
159
|
-
this.$div.empty().append($btnDiv);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Sets the real dimension of this panel.
|
|
164
|
-
* @override
|
|
165
|
-
* @param {module:AWT.Dimension} preferredMaxSize - The maximum surface available for the activity panel
|
|
166
|
-
* @returns {module:AWT.Dimension}
|
|
167
|
-
*/
|
|
168
|
-
setDimension(preferredMaxSize) {
|
|
169
|
-
return preferredMaxSize;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Basic initialization procedure
|
|
174
|
-
* @override
|
|
175
|
-
*/
|
|
176
|
-
initActivity() {
|
|
177
|
-
super.initActivity();
|
|
178
|
-
|
|
179
|
-
if (!this.firstRun)
|
|
180
|
-
this.buildVisualComponents();
|
|
181
|
-
else
|
|
182
|
-
this.firstRun = false;
|
|
183
|
-
|
|
184
|
-
this.setAndPlayMsg('initial', 'start');
|
|
185
|
-
this.playing = true;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Default icons used in buttons, inherited from JClic
|
|
191
|
-
* @type {object}
|
|
192
|
-
*/
|
|
193
|
-
MenuPanel.icons = {
|
|
194
|
-
'@ico00.png': ico00,
|
|
195
|
-
'@ico01.png': ico01,
|
|
196
|
-
'@ico02.png': ico02,
|
|
197
|
-
'@ico03.png': ico03,
|
|
198
|
-
'@icofolder.png': icoFolder,
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Panel class associated to this type of activity: {@link module:activities/panels/Menu.MenuPanel MenuPanel}
|
|
203
|
-
* @type {class} */
|
|
204
|
-
Menu.Panel = MenuPanel;
|
|
205
|
-
|
|
206
|
-
// Register activity class
|
|
207
|
-
export default Activity.registerClass('@panels.Menu', Menu);
|
|
208
|
-
|
|
209
|
-
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|