@oat-sa/tao-core-ui 1.5.4 → 1.6.3

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.
Files changed (43) hide show
  1. package/dist/ckeditor/ckConfigurator.js +9 -1
  2. package/dist/mediaEditor/mediaEditorComponent.js +5 -3
  3. package/dist/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +46 -25
  4. package/dist/mediaplayer/css/player.css +104 -14
  5. package/dist/mediaplayer/css/player.css.map +1 -1
  6. package/dist/mediaplayer/players/html5.js +767 -0
  7. package/dist/mediaplayer/players/youtube.js +470 -0
  8. package/dist/mediaplayer/players.js +35 -0
  9. package/dist/mediaplayer/support.js +134 -0
  10. package/dist/mediaplayer/utils/reminder.js +198 -0
  11. package/dist/mediaplayer/utils/timeObserver.js +149 -0
  12. package/dist/mediaplayer/youtubeManager.js +177 -0
  13. package/dist/mediaplayer.js +1251 -1912
  14. package/dist/previewer.js +25 -19
  15. package/package.json +1 -1
  16. package/scss/basic.scss +1 -0
  17. package/scss/inc/_jquery.nouislider.scss +254 -0
  18. package/src/ckeditor/ckConfigurator.js +10 -1
  19. package/src/itemButtonList/css/item-button-list.css +225 -0
  20. package/src/itemButtonList/css/item-button-list.css.map +1 -0
  21. package/src/mediaEditor/mediaEditorComponent.js +25 -26
  22. package/src/mediaEditor/plugins/mediaDimension/mediaDimensionComponent.js +83 -63
  23. package/src/mediaplayer/css/player.css +104 -14
  24. package/src/mediaplayer/css/player.css.map +1 -1
  25. package/src/mediaplayer/players/html5.js +564 -0
  26. package/src/mediaplayer/players/youtube.js +323 -0
  27. package/src/mediaplayer/players.js +29 -0
  28. package/src/mediaplayer/scss/player.scss +125 -16
  29. package/src/mediaplayer/support.js +126 -0
  30. package/src/mediaplayer/tpl/audio.tpl +6 -0
  31. package/src/mediaplayer/tpl/player.tpl +11 -32
  32. package/src/mediaplayer/tpl/source.tpl +1 -0
  33. package/src/mediaplayer/tpl/video.tpl +6 -0
  34. package/src/mediaplayer/tpl/youtube.tpl +1 -0
  35. package/src/mediaplayer/utils/reminder.js +184 -0
  36. package/src/mediaplayer/utils/timeObserver.js +143 -0
  37. package/src/mediaplayer/youtubeManager.js +161 -0
  38. package/src/mediaplayer.js +1217 -1901
  39. package/src/previewer.js +40 -33
  40. package/src/searchModal/css/advancedSearch.css +190 -0
  41. package/src/searchModal/css/advancedSearch.css.map +1 -0
  42. package/src/searchModal/css/searchModal.css +506 -0
  43. package/src/searchModal/css/searchModal.css.map +1 -0
@@ -0,0 +1,198 @@
1
+ define(function () { 'use strict';
2
+
3
+ /**
4
+ * This program is free software; you can redistribute it and/or
5
+ * modify it under the terms of the GNU General Public License
6
+ * as published by the Free Software Foundation; under version 2
7
+ * of the License (non-upgradable).
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU General Public License
15
+ * along with this program; if not, write to the Free Software
16
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+ *
18
+ * Copyright (c) 2021 (original work) Open Assessment Technologies SA ;
19
+ */
20
+
21
+ /**
22
+ * Creates a reminder manager.
23
+ *
24
+ * A reminder manager allows to register callback functions that will be called after a particular amount of time.
25
+ * The schedule can be created and cancelled at any time.
26
+ *
27
+ * @example
28
+ * // Create a reminder manager
29
+ * const manager = reminderManagerFactory();
30
+ *
31
+ * // Add a reminder that will be called after 2s (delay is given in milliseconds)
32
+ * manager.remind(() => console.log('Hello!'), 2000);
33
+ *
34
+ * // Start the schedule
35
+ * manager.start();
36
+ *
37
+ * // We can know how many time elapsed since the last schedule
38
+ * const elapsed = manager.elapsed;
39
+ *
40
+ * // The schedule can be cancelled
41
+ * if (needToCancel) {
42
+ * manager.stop();
43
+ * }
44
+ *
45
+ * // The schedule should be cancelled
46
+ * console.log('schedule running:', manager.running)
47
+ *
48
+ * @returns {reminderManager}
49
+ */
50
+ function reminderManagerFactory() {
51
+ // Keep track of the running state
52
+ var running = false; // Timestamp of the last start
53
+
54
+ var last = 0; // A list of reminders to callback
55
+
56
+ var reminders = new Map();
57
+ /**
58
+ * Cancels a schedule for a particular reminder.
59
+ * @param {object} state - A sate object containing the timeout handler for the reminder.
60
+ * @private
61
+ */
62
+
63
+ var stopReminder = function stopReminder(state) {
64
+ if (state && state.timeout) {
65
+ clearTimeout(state.timeout);
66
+ state.timeout = null;
67
+ }
68
+ };
69
+ /**
70
+ * Cancel the schedule for all reminders.
71
+ * @private
72
+ */
73
+
74
+
75
+ var stopAllReminders = function stopAllReminders() {
76
+ return reminders.forEach(stopReminder);
77
+ };
78
+ /**
79
+ * Schedule all reminders.
80
+ * @private
81
+ */
82
+
83
+
84
+ var startAllReminders = function startAllReminders() {
85
+ reminders.forEach(function (state, reminder) {
86
+ stopReminder(state);
87
+ state.timeout = setTimeout(reminder, state.delay);
88
+ });
89
+ };
90
+ /**
91
+ * Defines the API of a reminder manager.
92
+ *
93
+ * A reminder manager allows to register callback functions that will be called after a particular amount of time.
94
+ * The schedule can be created and cancelled at any time.
95
+ *
96
+ * @namespace reminderManager
97
+ */
98
+
99
+
100
+ return {
101
+ /**
102
+ * Tells whether or not the schedule is running.
103
+ * @type {boolean}
104
+ * @member running
105
+ * @memberOf reminderManager
106
+ */
107
+ get running() {
108
+ return running;
109
+ },
110
+
111
+ /**
112
+ * Gives the amount of time elapsed since the start of the schedule. It is given in milliseconds.
113
+ * If the schedule is not running, it will always be 0.
114
+ * @type {number}
115
+ * @member running
116
+ * @memberOf reminderManager
117
+ */
118
+ get elapsed() {
119
+ if (!running) {
120
+ return 0;
121
+ }
122
+
123
+ return performance.now() - last;
124
+ },
125
+
126
+ /**
127
+ * Schedules all reminders from now on.
128
+ *
129
+ * @returns {reminderManager}
130
+ * @function start
131
+ * @memberOf reminderManager
132
+ */
133
+ start: function start() {
134
+ running = true;
135
+ last = performance.now();
136
+ startAllReminders();
137
+ return this;
138
+ },
139
+
140
+ /**
141
+ * Cancels all scheduled reminders.
142
+ *
143
+ * @returns {reminderManager}
144
+ * @function stop
145
+ * @memberOf reminderManager
146
+ */
147
+ stop: function stop() {
148
+ running = false;
149
+ stopAllReminders();
150
+ return this;
151
+ },
152
+
153
+ /**
154
+ * Adds a callback to be scheduled.
155
+ * It won't be scheduled until the schedule is restarted.
156
+ *
157
+ * @param {Function} cb - A function to call after the delay elapsed.
158
+ * @param {number} delay - The delay after what call back the reminder. It is given in milliseconds.
159
+ * @returns {reminderManager}
160
+ * @function remind
161
+ * @memberOf reminderManager
162
+ */
163
+ remind: function remind(cb, delay) {
164
+ if ('function' === typeof cb && delay) {
165
+ stopReminder(reminders.get(cb));
166
+ reminders.set(cb, {
167
+ delay: delay
168
+ });
169
+ }
170
+
171
+ return this;
172
+ },
173
+
174
+ /**
175
+ * Removes a scheduled callback. If a schedule was running, it will be cancelled first.
176
+ *
177
+ * @param {Function} [cb] - The callback function to remove. If omitted, all reminders will be removed.
178
+ * @returns {reminderManager}
179
+ * @function forget
180
+ * @memberOf reminderManager
181
+ */
182
+ forget: function forget(cb) {
183
+ if ('undefined' !== typeof cb) {
184
+ stopReminder(reminders.get(cb));
185
+ reminders.delete(cb);
186
+ } else {
187
+ stopAllReminders();
188
+ reminders.clear();
189
+ }
190
+
191
+ return this;
192
+ }
193
+ };
194
+ }
195
+
196
+ return reminderManagerFactory;
197
+
198
+ });
@@ -0,0 +1,149 @@
1
+ define(['core/eventifier'], function (eventifier) { 'use strict';
2
+
3
+ eventifier = eventifier && eventifier.hasOwnProperty('default') ? eventifier['default'] : eventifier;
4
+
5
+ /**
6
+ * This program is free software; you can redistribute it and/or
7
+ * modify it under the terms of the GNU General Public License
8
+ * as published by the Free Software Foundation; under version 2
9
+ * of the License (non-upgradable).
10
+ *
11
+ * This program is distributed in the hope that it will be useful,
12
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ * GNU General Public License for more details.
15
+ *
16
+ * You should have received a copy of the GNU General Public License
17
+ * along with this program; if not, write to the Free Software
18
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
+ *
20
+ * Copyright (c) 2021 (original work) Open Assessment Technologies SA ;
21
+ */
22
+ /**
23
+ * Creates a time observer.
24
+ *
25
+ * It observes the updates applied to a timeline, raising a flag when an irregularity occurs.
26
+ *
27
+ * It works as follow:
28
+ * - an initial state is defined (example: current: 0, duration: 100)
29
+ * - each time a position is forced (say the position is changed outside of the regular time update), the observer needs
30
+ * to be notified.
31
+ * - each time the position is updated (say regular time update), the observer needs to be called.
32
+ * - if the difference between the last regular update and the last one is too high, an event is triggered
33
+ *
34
+ * @example
35
+ * // Create a time observer with an expected interval of 2 seconds
36
+ * const observer = timeObserverFactory(2);
37
+ *
38
+ * // Init the state
39
+ * observer.start(player.position, player.duration);
40
+ *
41
+ * // Update on a regular basis
42
+ * player.on('timeupdate', () => observer.update(player.position));
43
+ *
44
+ * // Notify any position change outside of the regular update
45
+ * player.on('seek', () => observer.seek(player.position));
46
+ *
47
+ * // Gets informed from any irregularity
48
+ * observer.on('irregularity', () => console.log('irregular jump in time');
49
+ *
50
+ * @param {number} interval - The typical interval expected between two updates. It is given in seconds.
51
+ * @returns {timeObserver}
52
+ */
53
+
54
+ function timeObserverFactory() {
55
+ var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
56
+ // Current time position
57
+ var position = 0; // Total duration expected
58
+
59
+ var duration = 0; // Last position forced
60
+
61
+ var _seek = 0;
62
+ /**
63
+ * Defines the API of a time observer.
64
+ *
65
+ * It observes the updates applied to a timeline, raising a flag when an irregularity occurs.
66
+ *
67
+ * @namespace timeObserver
68
+ */
69
+
70
+ return eventifier({
71
+ /**
72
+ * Gets the current time position reported to the observer.
73
+ *
74
+ * @returns {number}
75
+ * @type {number}
76
+ * @member position
77
+ * @memberOf timeObserver
78
+ */
79
+ get position() {
80
+ return position;
81
+ },
82
+
83
+ /**
84
+ * Gets the total duration reported to the observer.
85
+ *
86
+ * @returns {number}
87
+ * @type {number}
88
+ * @member duration
89
+ * @memberOf timeObserver
90
+ */
91
+ get duration() {
92
+ return duration;
93
+ },
94
+
95
+ /**
96
+ * Initialises the time state.
97
+ *
98
+ * @param {number} initPosition - The initial time position
99
+ * @param {number} initDuration - The total duration expected
100
+ * @returns {timeObserver}
101
+ * @function init
102
+ * @memberOf timeObserver
103
+ */
104
+ init: function init(initPosition, initDuration) {
105
+ position = _seek = initPosition;
106
+ duration = initDuration;
107
+ return this;
108
+ },
109
+
110
+ /**
111
+ * Updates the time position. If the difference with the previous update is too high, an `irregularity` event
112
+ * will be emitted.
113
+ *
114
+ * @param {number} newPosition - The new time position
115
+ * @returns {timeObserver}
116
+ *
117
+ * @fires irregularity
118
+ */
119
+ update: function update(newPosition) {
120
+ if (newPosition > _seek && newPosition - position > interval) {
121
+ /**
122
+ * Notifies an irregularity in the time update
123
+ * @event irregularity
124
+ * @param {number} position - last regular position
125
+ * @param {number} newPosition - new irregular position
126
+ */
127
+ this.trigger('irregularity', position, newPosition);
128
+ }
129
+
130
+ position = newPosition;
131
+ return this;
132
+ },
133
+
134
+ /**
135
+ * Notifies the observer about a change in the position outside of the regular update.
136
+ *
137
+ * @param {number} seekPosition
138
+ * @returns {timeObserver}
139
+ */
140
+ seek: function seek(seekPosition) {
141
+ position = _seek = seekPosition;
142
+ return this;
143
+ }
144
+ });
145
+ }
146
+
147
+ return timeObserverFactory;
148
+
149
+ });
@@ -0,0 +1,177 @@
1
+ define(['jquery'], function ($) { 'use strict';
2
+
3
+ $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
4
+
5
+ function _toConsumableArray(arr) {
6
+ return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread();
7
+ }
8
+
9
+ function _arrayWithoutHoles(arr) {
10
+ if (Array.isArray(arr)) {
11
+ for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
12
+
13
+ return arr2;
14
+ }
15
+ }
16
+
17
+ function _iterableToArray(iter) {
18
+ if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
19
+ }
20
+
21
+ function _nonIterableSpread() {
22
+ throw new TypeError("Invalid attempt to spread non-iterable instance");
23
+ }
24
+
25
+ /**
26
+ * CDN for the YouTube API
27
+ * @type {String}
28
+ */
29
+
30
+ var youtubeApi = 'https://www.youtube.com/iframe_api';
31
+ /**
32
+ * A Regex to extract ID from Youtube URLs
33
+ * @type {RegExp}
34
+ */
35
+
36
+ var reYoutube = /([?&\/]v[=\/])([\w-]+)([&\/]?)/;
37
+ /**
38
+ * Installs a Youtube player. The Youtube API must be ready
39
+ * @param {String|jQuery|HTMLElement} elem
40
+ * @param {Object} player
41
+ * @param {Object} [options]
42
+ * @param {Boolean} [options.controls]
43
+ */
44
+
45
+ function addYoutubePlayer(elem, player) {
46
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
47
+ var $elem = $(elem);
48
+ new window.YT.Player($elem.get(0), {
49
+ height: '360',
50
+ width: '640',
51
+ videoId: $elem.data('videoId'),
52
+ playerVars: {
53
+ //hd: true,
54
+ autoplay: 0,
55
+ controls: options && options.controls ? 1 : 0,
56
+ rel: 0,
57
+ showinfo: 0,
58
+ wmode: 'transparent',
59
+ modestbranding: 1,
60
+ disablekb: 1,
61
+ playsinline: 1,
62
+ enablejsapi: 1,
63
+ origin: location.hostname
64
+ },
65
+ events: {
66
+ onReady: function onReady(ev) {
67
+ return player.onReady(ev);
68
+ },
69
+ onStateChange: function onStateChange(ev) {
70
+ return player.onStateChange(ev);
71
+ }
72
+ }
73
+ });
74
+ }
75
+ /**
76
+ * A local manager for Youtube players.
77
+ * Relies on https://developers.google.com/youtube/iframe_api_reference
78
+ * @type {Object}
79
+ */
80
+
81
+
82
+ function youtubeManagerFactory() {
83
+ // The Youtube API injection state
84
+ var injected = false; // The Youtube API ready state
85
+
86
+ var ready = false; // A list of pending players
87
+
88
+ var pending = [];
89
+ /**
90
+ * Checks if the Youtube API is ready to use
91
+ * @returns {Boolean}
92
+ */
93
+
94
+ function isApiReady() {
95
+ var apiReady = typeof window.YT !== 'undefined' && typeof window.YT.Player !== 'undefined';
96
+
97
+ if (apiReady && !ready) {
98
+ ready = true;
99
+ pending.forEach(function (args) {
100
+ if (args) {
101
+ addYoutubePlayer.apply(void 0, _toConsumableArray(args));
102
+ }
103
+ });
104
+ pending = [];
105
+ }
106
+
107
+ return apiReady;
108
+ }
109
+ /**
110
+ * Injects the Youtube API into the page
111
+ */
112
+
113
+
114
+ function injectApi() {
115
+ if (!isApiReady()) {
116
+ window.require([youtubeApi], function () {
117
+ var check = function check() {
118
+ if (!isApiReady()) {
119
+ setTimeout(check, 100);
120
+ }
121
+ };
122
+
123
+ check();
124
+ });
125
+ }
126
+
127
+ injected = true;
128
+ }
129
+
130
+ return {
131
+ /**
132
+ * Adds a Youtube player
133
+ * @param {String|jQuery|HTMLElement} elem
134
+ * @param {Object} player
135
+ * @param {Object} [options]
136
+ * @param {Boolean} [options.controls]
137
+ */
138
+ add: function add(elem, player, options) {
139
+ if (ready) {
140
+ addYoutubePlayer(elem, player, options);
141
+ } else {
142
+ pending.push([elem, player, options]);
143
+
144
+ if (!injected) {
145
+ injectApi();
146
+ }
147
+ }
148
+ },
149
+
150
+ /**
151
+ * Removes a pending Youtube player
152
+ * @param {String|jQuery|HTMLElement} elem
153
+ * @param {Object} player
154
+ */
155
+ remove: function remove(elem, player) {
156
+ pending.forEach(function (args, idx) {
157
+ if (args && elem === args[0] && player === args[1]) {
158
+ pending[idx] = null;
159
+ }
160
+ });
161
+ },
162
+
163
+ /**
164
+ * Extracts the ID of a Youtube video from an URL
165
+ * @param {String} url
166
+ * @returns {String}
167
+ */
168
+ extractYoutubeId: function extractYoutubeId(url) {
169
+ var res = reYoutube.exec(url);
170
+ return res && res[2] || url;
171
+ }
172
+ };
173
+ }
174
+
175
+ return youtubeManagerFactory;
176
+
177
+ });