videomail-client 8.3.1 → 8.3.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.
Files changed (38) hide show
  1. package/package.json +1 -1
  2. package/prototype/js/videomail-client.js +12 -14
  3. package/prototype/js/videomail-client.min.js +1 -1
  4. package/prototype/js/videomail-client.min.js.map +1 -1
  5. package/src/js/client.js +0 -210
  6. package/src/js/constants.js +0 -11
  7. package/src/js/events.js +0 -46
  8. package/src/js/index.js +0 -15
  9. package/src/js/options.js +0 -180
  10. package/src/js/resource.js +0 -206
  11. package/src/js/util/audioRecorder.js +0 -152
  12. package/src/js/util/browser.js +0 -319
  13. package/src/js/util/collectLogger.js +0 -72
  14. package/src/js/util/eventEmitter.js +0 -72
  15. package/src/js/util/humanize.js +0 -16
  16. package/src/js/util/mediaEvents.js +0 -148
  17. package/src/js/util/pretty.js +0 -70
  18. package/src/js/util/standardize.js +0 -71
  19. package/src/js/util/videomailError.js +0 -431
  20. package/src/js/wrappers/buttons.js +0 -670
  21. package/src/js/wrappers/container.js +0 -797
  22. package/src/js/wrappers/dimension.js +0 -149
  23. package/src/js/wrappers/form.js +0 -319
  24. package/src/js/wrappers/optionsWrapper.js +0 -81
  25. package/src/js/wrappers/visuals/inside/recorder/countdown.js +0 -83
  26. package/src/js/wrappers/visuals/inside/recorder/facingMode.js +0 -53
  27. package/src/js/wrappers/visuals/inside/recorder/pausedNote.js +0 -59
  28. package/src/js/wrappers/visuals/inside/recorder/recordNote.js +0 -42
  29. package/src/js/wrappers/visuals/inside/recorder/recordTimer.js +0 -149
  30. package/src/js/wrappers/visuals/inside/recorderInsides.js +0 -144
  31. package/src/js/wrappers/visuals/notifier.js +0 -341
  32. package/src/js/wrappers/visuals/recorder.js +0 -1492
  33. package/src/js/wrappers/visuals/replay.js +0 -355
  34. package/src/js/wrappers/visuals/userMedia.js +0 -541
  35. package/src/js/wrappers/visuals.js +0 -410
  36. package/src/styles/css/main.min.css.js +0 -1
  37. package/src/styles/styl/keyframes/blink.styl +0 -16
  38. package/src/styles/styl/main.styl +0 -126
@@ -1,670 +0,0 @@
1
- import contains from "contains";
2
- import hidden from "hidden";
3
- import h from "hyperscript";
4
- import inherits from "inherits";
5
-
6
- import Events from "../events";
7
- import EventEmitter from "../util/eventEmitter";
8
-
9
- const Buttons = function (container, options) {
10
- EventEmitter.call(this, options, "Buttons");
11
-
12
- const self = this;
13
- const { debug } = options;
14
-
15
- let buttonsElement;
16
- let recordButton;
17
- let pauseButton;
18
- let resumeButton;
19
- let previewButton;
20
- let recordAgainButton;
21
- let submitButton;
22
-
23
- let audioOnRadioPair;
24
- let audioOffRadioPair;
25
-
26
- let built;
27
-
28
- function hide(elements) {
29
- if (elements && !Array.isArray(elements)) {
30
- elements = [elements];
31
- }
32
-
33
- elements &&
34
- elements.forEach(function (element) {
35
- hidden(element, true);
36
- });
37
- }
38
-
39
- function show(elements) {
40
- if (elements && !Array.isArray(elements)) {
41
- elements = [elements];
42
- }
43
-
44
- elements &&
45
- elements.forEach(function (element) {
46
- hidden(element, false);
47
- });
48
- }
49
-
50
- function isShown(elements) {
51
- let isShown = elements && true;
52
-
53
- if (elements && !Array.isArray(elements)) {
54
- elements = [elements];
55
- }
56
-
57
- elements &&
58
- elements.forEach(function (element) {
59
- isShown &&= element && !hidden(element);
60
- });
61
-
62
- return isShown;
63
- }
64
-
65
- function disable(elements) {
66
- if (elements && !Array.isArray(elements)) {
67
- elements = [elements];
68
- }
69
-
70
- elements &&
71
- elements.forEach(function (element) {
72
- // https://github.com/binarykitchen/videomail-client/issues/148
73
- if (element) {
74
- if (element.tagName === "INPUT" || element.tagName === "BUTTON") {
75
- element.disabled = true;
76
- } else {
77
- element.classList.add("disabled");
78
- }
79
- }
80
- });
81
- }
82
-
83
- function enable(elements) {
84
- if (elements && !Array.isArray(elements)) {
85
- elements = [elements];
86
- }
87
-
88
- elements &&
89
- elements.forEach(function (element) {
90
- // https://github.com/binarykitchen/videomail-client/issues/148
91
- if (element) {
92
- if (element.tagName === "INPUT" || element.tagName === "BUTTON") {
93
- element.disabled = false;
94
- } else {
95
- element.classList.remove("disabled");
96
- }
97
- }
98
- });
99
- }
100
-
101
- function adjustButton(buttonElement, show, type, disabled) {
102
- if (disabled) {
103
- disable(buttonElement);
104
- }
105
-
106
- if (type) {
107
- buttonElement.type = type;
108
- } else if (!buttonElement.type) {
109
- buttonElement.type = "button";
110
- }
111
-
112
- !show && hide(buttonElement);
113
-
114
- return buttonElement;
115
- }
116
-
117
- function replaceClickHandler(element, clickHandler) {
118
- const wrappedClickHandler = (e) => {
119
- e && e.preventDefault();
120
-
121
- try {
122
- clickHandler({ event: e });
123
- } catch (exc) {
124
- self.emit(Events.ERROR, exc);
125
- }
126
- };
127
-
128
- element.onclick = wrappedClickHandler;
129
- }
130
-
131
- function makeRadioButtonPair(options) {
132
- let radioButtonElement;
133
- let radioButtonGroup;
134
-
135
- if (options.id) {
136
- radioButtonElement = document.getElementById(options.id);
137
- }
138
-
139
- if (!radioButtonElement) {
140
- radioButtonElement = h(`input#${options.id}`, {
141
- type: "radio",
142
- name: options.name,
143
- value: options.value,
144
- checked: options.checked,
145
- });
146
-
147
- radioButtonGroup = h(
148
- "span.radioGroup",
149
- radioButtonElement,
150
- h(
151
- "label",
152
- {
153
- htmlFor: options.id,
154
- },
155
- options.label,
156
- ),
157
- );
158
-
159
- // double check that submit button is already in the buttonsElement container as a child?
160
- if (submitButton && contains(buttonsElement, submitButton)) {
161
- buttonsElement.insertBefore(radioButtonGroup, submitButton);
162
- } else {
163
- buttonsElement.appendChild(radioButtonGroup);
164
- }
165
- }
166
-
167
- if (options.changeHandler) {
168
- radioButtonElement.onchange = options.changeHandler;
169
- }
170
-
171
- disable(radioButtonElement);
172
-
173
- return [radioButtonElement, radioButtonGroup];
174
- }
175
-
176
- function makeButton(
177
- buttonClass,
178
- text,
179
- clickHandler,
180
- show,
181
- id,
182
- type,
183
- selector,
184
- disabled = true,
185
- ) {
186
- let buttonElement;
187
-
188
- if (id) {
189
- buttonElement = document.getElementById(id);
190
- } else if (selector) {
191
- buttonElement = document.querySelector(selector);
192
- } else {
193
- buttonElement = buttonsElement.querySelector(`.${buttonClass}`);
194
- }
195
-
196
- if (!buttonElement) {
197
- if (options.selectors.buttonClass) {
198
- buttonClass += `.${options.selectors.buttonClass}`;
199
- }
200
-
201
- buttonElement = h(`button.${buttonClass}`);
202
- buttonElement = adjustButton(buttonElement, show, type, disabled);
203
-
204
- buttonElement.innerHTML = text;
205
-
206
- // double check that submit button is already in the buttonsElement container
207
- if (submitButton && contains(buttonsElement, submitButton)) {
208
- buttonsElement.insertBefore(buttonElement, submitButton);
209
- } else {
210
- buttonsElement.appendChild(buttonElement);
211
- }
212
- } else {
213
- buttonElement = adjustButton(buttonElement, show, type, disabled);
214
- }
215
-
216
- if (clickHandler) {
217
- replaceClickHandler(buttonElement, clickHandler);
218
- }
219
-
220
- return buttonElement;
221
- }
222
-
223
- function buildButtons() {
224
- if (!options.disableSubmit) {
225
- if (!submitButton) {
226
- submitButton = makeButton(
227
- options.selectors.submitButtonClass,
228
- "Submit",
229
- null,
230
- true,
231
- options.selectors.submitButtonId,
232
- "submit",
233
- options.selectors.submitButtonSelector,
234
- options.enableAutoValidation,
235
- );
236
- } else {
237
- disable(submitButton);
238
- }
239
-
240
- /*
241
- * no need to listen to the submit event when it's already listened
242
- * within the form element class
243
- */
244
- if (!container.hasForm() && submitButton) {
245
- replaceClickHandler(submitButton, submit);
246
- }
247
- }
248
-
249
- recordButton = makeButton(
250
- options.selectors.recordButtonClass,
251
- options.text.buttons.record,
252
- record,
253
- false,
254
- );
255
-
256
- if (options.enablePause) {
257
- pauseButton = makeButton(
258
- options.selectors.pauseButtonClass,
259
- options.text.buttons.pause,
260
- container.pause,
261
- false,
262
- );
263
- }
264
-
265
- if (options.enablePause) {
266
- resumeButton = makeButton(
267
- options.selectors.resumeButtonClass,
268
- options.text.buttons.resume,
269
- container.resume,
270
- false,
271
- );
272
- }
273
-
274
- /*
275
- * show stop only when pause is enabled - looks better that way otherwise button
276
- * move left and right between record and stop (preview)
277
- */
278
- previewButton = makeButton(
279
- options.selectors.previewButtonClass,
280
- options.text.buttons.preview,
281
- container.stop,
282
- false,
283
- );
284
-
285
- recordAgainButton = makeButton(
286
- options.selectors.recordAgainButtonClass,
287
- options.text.buttons.recordAgain,
288
- recordAgain,
289
- false,
290
- );
291
-
292
- if (options.audio && options.audio.switch) {
293
- audioOffRadioPair = makeRadioButtonPair({
294
- id: "audioOffOption",
295
- name: "audio",
296
- value: "off",
297
- label: options.text.audioOff,
298
- checked: !options.isAudioEnabled(),
299
- changeHandler() {
300
- container.disableAudio();
301
- },
302
- });
303
-
304
- audioOnRadioPair = makeRadioButtonPair({
305
- id: "audioOnOption",
306
- name: "audio",
307
- value: "on",
308
- label: options.text.audioOn,
309
- checked: options.isAudioEnabled(),
310
- changeHandler() {
311
- container.enableAudio();
312
- },
313
- });
314
- }
315
- }
316
-
317
- function onFormReady(params) {
318
- // no need to show record button when doing a record again
319
- if (!isShown(recordAgainButton)) {
320
- if (!params.paused) {
321
- show(recordButton);
322
- }
323
- }
324
-
325
- if (!params.paused) {
326
- disable(previewButton);
327
- hide(previewButton);
328
- }
329
-
330
- if (!options.enableAutoValidation) {
331
- enable(submitButton);
332
- }
333
-
334
- if (!params.recordWhenReady) {
335
- if (isShown(audioOnRadioPair)) {
336
- enable(audioOnRadioPair);
337
- }
338
-
339
- if (isShown(audioOffRadioPair)) {
340
- enable(audioOffRadioPair);
341
- }
342
- }
343
- }
344
-
345
- function onGoingBack() {
346
- hide(recordAgainButton);
347
- show(recordButton);
348
- show(submitButton);
349
- }
350
-
351
- function onReplayShown() {
352
- self.hide();
353
- }
354
-
355
- function onUserMediaReady(params) {
356
- onFormReady(params);
357
-
358
- if (isShown(recordButton) && !params.recordWhenReady) {
359
- enable(recordButton);
360
- }
361
-
362
- if (options.enableAutoValidation) {
363
- disable(submitButton);
364
- }
365
- }
366
-
367
- function onResetting() {
368
- disable(submitButton);
369
-
370
- self.reset();
371
- }
372
-
373
- function onPreview() {
374
- hide(recordButton);
375
- hide(previewButton);
376
- disable(audioOnRadioPair);
377
- disable(audioOffRadioPair);
378
-
379
- show(recordAgainButton);
380
- enable(recordAgainButton);
381
-
382
- if (!options.enableAutoValidation) {
383
- enable(submitButton);
384
- }
385
- }
386
-
387
- this.enableSubmit = function () {
388
- enable(submitButton);
389
- };
390
-
391
- this.adjustButtonsForPause = function () {
392
- if (!self.isCountingDown()) {
393
- pauseButton && hide(pauseButton);
394
- show(resumeButton);
395
- enable(resumeButton);
396
- hide(recordButton);
397
- show(previewButton);
398
- enable(previewButton);
399
- }
400
- };
401
-
402
- function onFirstFrameSent() {
403
- hide(recordButton);
404
- hide(recordAgainButton);
405
-
406
- if (pauseButton) {
407
- show(pauseButton);
408
- enable(pauseButton);
409
- }
410
-
411
- enable(previewButton);
412
- show(previewButton);
413
- }
414
-
415
- function onRecording(framesCount) {
416
- /*
417
- * it is possible to hide while recording, hence
418
- * check framesCount first (coming from recorder)
419
- */
420
- if (framesCount > 1) {
421
- onFirstFrameSent();
422
- } else {
423
- disable(audioOffRadioPair);
424
- disable(audioOnRadioPair);
425
- disable(recordAgainButton);
426
- disable(recordButton);
427
- }
428
- }
429
-
430
- function onResuming() {
431
- hide(resumeButton);
432
- hide(recordButton);
433
-
434
- if (pauseButton) {
435
- enable(pauseButton);
436
- show(pauseButton);
437
- }
438
- }
439
-
440
- function onStopping() {
441
- disable(previewButton);
442
- disable(recordButton);
443
-
444
- hide(pauseButton);
445
- hide(resumeButton);
446
- }
447
-
448
- function onCountdown() {
449
- disable(recordButton);
450
- disable(audioOffRadioPair);
451
- disable(audioOnRadioPair);
452
- }
453
-
454
- function onSubmitting() {
455
- disable(submitButton);
456
- disable(recordAgainButton);
457
- }
458
-
459
- function onSubmitted() {
460
- disable(previewButton);
461
- disable(recordAgainButton);
462
- disable(recordButton);
463
- disable(submitButton);
464
- }
465
-
466
- function onInvalid() {
467
- if (options.enableAutoValidation) {
468
- disable(submitButton);
469
- }
470
- }
471
-
472
- function onValid() {
473
- if (options.enableAutoValidation) {
474
- enable(submitButton);
475
- }
476
- }
477
-
478
- function onHidden() {
479
- hide(recordButton);
480
- hide(previewButton);
481
- hide(recordAgainButton);
482
- hide(resumeButton);
483
- }
484
-
485
- function onEnablingAudio() {
486
- disable(recordButton);
487
- disable(audioOnRadioPair);
488
- disable(audioOffRadioPair);
489
- }
490
-
491
- function onDisablingAudio() {
492
- disable(recordButton);
493
- disable(audioOnRadioPair);
494
- disable(audioOffRadioPair);
495
- }
496
-
497
- function recordAgain() {
498
- disable(recordAgainButton);
499
- container.beginWaiting();
500
- container.recordAgain();
501
- }
502
-
503
- function onStartingOver() {
504
- show(submitButton);
505
- }
506
-
507
- function submit() {
508
- container.submit();
509
- }
510
-
511
- function record(params) {
512
- disable(recordButton);
513
- container.record(params);
514
- }
515
-
516
- function initEvents() {
517
- debug("Buttons: initEvents()");
518
-
519
- self
520
- .on(Events.USER_MEDIA_READY, function (params) {
521
- if (!params.switchingFacingMode) {
522
- onUserMediaReady(params);
523
- }
524
- })
525
- .on(Events.PREVIEW, function () {
526
- onPreview();
527
- })
528
- .on(Events.PAUSED, function () {
529
- self.adjustButtonsForPause();
530
- })
531
- .on(Events.RECORDING, function (framesCount) {
532
- onRecording(framesCount);
533
- })
534
- .on(Events.FIRST_FRAME_SENT, function () {
535
- onFirstFrameSent();
536
- })
537
- .on(Events.RESUMING, function () {
538
- onResuming();
539
- })
540
- .on(Events.STOPPING, function () {
541
- onStopping();
542
- })
543
- .on(Events.COUNTDOWN, function () {
544
- onCountdown();
545
- })
546
- .on(Events.SUBMITTING, function () {
547
- onSubmitting();
548
- })
549
- .on(Events.RESETTING, function () {
550
- onResetting();
551
- })
552
- .on(Events.INVALID, function () {
553
- onInvalid();
554
- })
555
- .on(Events.VALID, function () {
556
- onValid();
557
- })
558
- .on(Events.SUBMITTED, function () {
559
- onSubmitted();
560
- })
561
- .on(Events.HIDE, function () {
562
- onHidden();
563
- })
564
- .on(Events.FORM_READY, function (params) {
565
- onFormReady(params);
566
- })
567
- .on(Events.REPLAY_SHOWN, function () {
568
- onReplayShown();
569
- })
570
- .on(Events.GOING_BACK, function () {
571
- onGoingBack();
572
- })
573
- .on(Events.ENABLING_AUDIO, function () {
574
- onEnablingAudio();
575
- })
576
- .on(Events.DISABLING_AUDIO, function () {
577
- onDisablingAudio();
578
- })
579
- .on(Events.STARTING_OVER, function () {
580
- onStartingOver();
581
- })
582
- .on(Events.CONNECTED, function () {
583
- if (options.loadUserMediaOnRecord) {
584
- if (isShown(recordButton)) {
585
- enable(recordButton);
586
- }
587
- }
588
- })
589
- .on(Events.ERROR, function (err) {
590
- /*
591
- * since https://github.com/binarykitchen/videomail-client/issues/60
592
- * we hide areas to make it easier for the user
593
- */
594
- if (err.hideButtons && err.hideButtons() && options.adjustFormOnBrowserError) {
595
- self.hide();
596
- }
597
- });
598
- }
599
-
600
- this.reset = function () {
601
- options.debug("Buttons: reset()");
602
-
603
- disable(pauseButton);
604
- disable(resumeButton);
605
- disable(recordButton);
606
- disable(previewButton);
607
- disable(recordAgainButton);
608
- };
609
-
610
- this.isRecordAgainButtonEnabled = function () {
611
- return !recordAgainButton.disabled;
612
- };
613
-
614
- this.isRecordButtonEnabled = function () {
615
- return !recordButton.disabled;
616
- };
617
-
618
- this.setSubmitButton = function (newSubmitButton) {
619
- submitButton = newSubmitButton;
620
- };
621
-
622
- this.getSubmitButton = function () {
623
- return submitButton;
624
- };
625
-
626
- this.build = function () {
627
- buttonsElement = container.querySelector(`.${options.selectors.buttonsClass}`);
628
-
629
- if (!buttonsElement) {
630
- buttonsElement = h(`div.${options.selectors.buttonsClass}`);
631
-
632
- container.appendChild(buttonsElement);
633
- }
634
-
635
- buildButtons();
636
-
637
- !built && initEvents();
638
-
639
- built = true;
640
- };
641
-
642
- this.unload = function () {
643
- built = false;
644
- };
645
-
646
- this.hide = function (params) {
647
- hide(buttonsElement);
648
-
649
- if (params && params.deep) {
650
- hide(recordButton);
651
- hide(pauseButton);
652
- hide(resumeButton);
653
- hide(previewButton);
654
- hide(recordAgainButton);
655
- hide(submitButton);
656
- }
657
- };
658
-
659
- this.show = function () {
660
- show(buttonsElement);
661
- };
662
-
663
- this.isCountingDown = function () {
664
- return container.isCountingDown();
665
- };
666
- };
667
-
668
- inherits(Buttons, EventEmitter);
669
-
670
- export default Buttons;