highmark-cli 0.0.138 → 0.0.140

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 (92) hide show
  1. package/bin/action/publish.js +2 -0
  2. package/bin/constants.js +6 -2
  3. package/bin/handler/liveReload.js +18 -0
  4. package/bin/importer.js +7 -4
  5. package/bin/operation/copyCheckmark.js +32 -0
  6. package/bin/operation/copyClient.js +5 -5
  7. package/bin/operation/markdownHTML.js +31 -9
  8. package/bin/operation/markdownStylesCSS.js +17 -10
  9. package/bin/operation/server.js +7 -10
  10. package/bin/router/static.js +17 -0
  11. package/checkmark.svg +12 -0
  12. package/client.js +6126 -1527
  13. package/css/loading.css +32 -32
  14. package/lib/client.js +48 -6
  15. package/lib/constants.js +28 -12
  16. package/lib/createMethods.js +64 -0
  17. package/lib/customEventTypes.js +9 -1
  18. package/lib/eventTypes.js +5 -1
  19. package/lib/localStorage.js +56 -0
  20. package/lib/mixins/fullsrean.js +63 -0
  21. package/lib/mixins/touch.js +101 -32
  22. package/lib/selectors.js +5 -9
  23. package/lib/state.js +133 -0
  24. package/lib/styles.js +78 -0
  25. package/lib/utilities/element.js +11 -11
  26. package/lib/utilities/fullScreen.js +16 -0
  27. package/lib/utilities/orientation.js +39 -0
  28. package/lib/view/button/closeMenu.js +121 -0
  29. package/lib/view/button/fullScreen.js +121 -0
  30. package/lib/view/button/zoomMenuIn.js +121 -0
  31. package/lib/view/button/zoomMenuOut.js +121 -0
  32. package/lib/view/button.js +160 -0
  33. package/lib/view/checkbox.js +193 -0
  34. package/lib/view/div/buttons.js +215 -0
  35. package/lib/view/div/checkbox/invertColours.js +151 -0
  36. package/lib/view/div/checkbox/restoreNativeGestures.js +147 -0
  37. package/lib/view/div/checkbox.js +220 -0
  38. package/lib/view/div/checkboxes.js +211 -0
  39. package/lib/view/div/menu.js +122 -28
  40. package/lib/view/div/overlay.js +639 -0
  41. package/lib/view/div/preloader.js +204 -0
  42. package/lib/view/{div/leaf.js → div.js} +21 -32
  43. package/lib/view/element.js +164 -0
  44. package/lib/view/span.js +182 -0
  45. package/lib/view/svg/closeMenu.js +138 -0
  46. package/lib/view/svg/fullScreen.js +138 -0
  47. package/lib/view/svg/zoomMenuIn.js +146 -0
  48. package/lib/view/svg/zoomMenuOut.js +141 -0
  49. package/lib/view/svg.js +184 -0
  50. package/lib/view.js +23 -396
  51. package/package.json +3 -2
  52. package/src/client.js +34 -8
  53. package/src/constants.js +7 -3
  54. package/src/createMethods.js +66 -0
  55. package/src/customEventTypes.js +2 -0
  56. package/src/eventTypes.js +1 -0
  57. package/src/localStorage.js +48 -0
  58. package/src/mixins/fullsrean.js +75 -0
  59. package/src/mixins/touch.js +98 -39
  60. package/src/selectors.js +1 -2
  61. package/src/state.js +130 -0
  62. package/src/styles.js +18 -0
  63. package/src/utilities/element.js +18 -15
  64. package/src/utilities/fullScreen.js +8 -0
  65. package/src/utilities/orientation.js +34 -0
  66. package/src/view/button/closeMenu.js +16 -0
  67. package/src/view/button/fullScreen.js +16 -0
  68. package/src/view/button/zoomMenuIn.js +16 -0
  69. package/src/view/button/zoomMenuOut.js +16 -0
  70. package/src/view/button.js +38 -0
  71. package/src/view/checkbox.js +68 -0
  72. package/src/view/div/buttons.js +39 -0
  73. package/src/view/div/checkbox/invertColours.js +33 -0
  74. package/src/view/div/checkbox/restoreNativeGestures.js +29 -0
  75. package/src/view/div/checkbox.js +45 -0
  76. package/src/view/div/checkboxes.js +36 -0
  77. package/src/view/div/menu.js +83 -26
  78. package/src/view/div/overlay.js +547 -0
  79. package/src/view/div/preloader.js +25 -0
  80. package/src/view/{div/leaf.js → div.js} +13 -21
  81. package/src/view/element.js +16 -0
  82. package/src/view/span.js +22 -0
  83. package/src/view/svg/closeMenu.js +19 -0
  84. package/src/view/svg/fullScreen.js +19 -0
  85. package/src/view/svg/zoomMenuIn.js +20 -0
  86. package/src/view/svg/zoomMenuOut.js +19 -0
  87. package/src/view/svg.js +24 -0
  88. package/src/view.js +20 -482
  89. package/lib/style.js +0 -13
  90. package/lib/utilities/tree.js +0 -55
  91. package/src/style.js +0 -3
  92. package/src/utilities/tree.js +0 -29
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+
3
+ export default function createMethods(scheduler, model, view) {
4
+ function openMenu() {
5
+ view.openMenu();
6
+ }
7
+
8
+ function closeMenu() {
9
+ view.closeMenu();
10
+ }
11
+
12
+ function zoomMenuIn() {
13
+ view.zoomMenuIn();
14
+ }
15
+
16
+ function zoomMenuOut() {
17
+ view.zoomMenuOut();
18
+ }
19
+
20
+ function invertColours() {
21
+ view.invertColours();
22
+ }
23
+
24
+ function revertColours() {
25
+ view.revertColours();
26
+ }
27
+
28
+ function exitFullScreen() {
29
+ view.exitFullScreen();
30
+ }
31
+
32
+ function enterFullScreen() {
33
+ view.enterFullScreen();
34
+ }
35
+
36
+ function restoreNativeGestures() {
37
+ view.restoreNativeGestures();
38
+ }
39
+
40
+ function suppressNativeGestures() {
41
+ view.suppressNativeGestures();
42
+ }
43
+
44
+ function checkRestoreNativeGesturesCheckbox(checked) {
45
+ view.checkRestoreNativeGesturesCheckbox(checked);
46
+ }
47
+
48
+ function uncheckRestoreNativeGesturesCheckbox(checked) {
49
+ view.uncheckRestoreNativeGesturesCheckbox(checked);
50
+ }
51
+
52
+ return ({
53
+ openMenu,
54
+ closeMenu,
55
+ zoomMenuIn,
56
+ zoomMenuOut,
57
+ invertColours,
58
+ revertColours,
59
+ exitFullScreen,
60
+ enterFullScreen,
61
+ restoreNativeGestures,
62
+ suppressNativeGestures,
63
+ checkRestoreNativeGesturesCheckbox,
64
+ uncheckRestoreNativeGesturesCheckbox
65
+ });
66
+ }
@@ -6,6 +6,7 @@ export const DRAG_DOWN_CUSTOM_EVENT_TYPE = "drag-down";
6
6
  export const DRAG_LEFT_CUSTOM_EVENT_TYPE = "drag-left";
7
7
  export const DRAG_RIGHT_CUSTOM_EVENT_TYPE = "drag-right";
8
8
  export const DRAG_START_CUSTOM_EVENT_TYPE = "drag-start";
9
+ export const DRAG_END_CUSTOM_EVENT_TYPE = "drag-end";
9
10
  export const SWIPE_UP_CUSTOM_EVENT_TYPE = "swipe-up";
10
11
  export const SWIPE_DOWN_CUSTOM_EVENT_TYPE = "swipe-down";
11
12
  export const SWIPE_LEFT_CUSTOM_EVENT_TYPE = "swipe-left";
@@ -13,3 +14,4 @@ export const SWIPE_RIGHT_CUSTOM_EVENT_TYPE = "swipe-right";
13
14
  export const PINCH_MOVE_CUSTOM_EVENT_TYPE = "pinch-move";
14
15
  export const PINCH_START_CUSTOM_EVENT_TYPE = "pinch-start";
15
16
  export const DOUBLE_TAP_CUSTOM_EVENT_TYPE = "double-tap";
17
+ export const FULL_SCREEN_CHANGE_CUSTOM_EVENT_TYPE = "full-screen-change";
package/src/eventTypes.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ export const FULLSCREENCHANGE_EVENT_TYPE = "fullscreenchange";
3
4
  export const TOUCHSTART_EVENT_TYPE = "touchstart";
4
5
  export const TOUCHMOVE_EVENT_TYPE = "touchmove";
5
6
  export const TOUCHEND_EVENT_TYPE = "touchend";
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+
3
+ import { STATE_KEY, LANDSCAPE_ORIENTATION, PORTRAIT_ORIENTATION } from "./constants";
4
+
5
+ const viewZoom = {
6
+ [PORTRAIT_ORIENTATION]: 1,
7
+ [LANDSCAPE_ORIENTATION]: 1
8
+ },
9
+ menuDivZoom = {
10
+ [PORTRAIT_ORIENTATION]: 1,
11
+ [LANDSCAPE_ORIENTATION]: 1
12
+ },
13
+ fullScreenViewZoom = {
14
+ [PORTRAIT_ORIENTATION]: 1,
15
+ [LANDSCAPE_ORIENTATION]: 1
16
+ },
17
+ coloursInverted = false,
18
+ defaultPersistentState = {
19
+ viewZoom,
20
+ menuDivZoom,
21
+ fullScreenViewZoom,
22
+ coloursInverted
23
+ };
24
+
25
+ export function getPersistentState() {
26
+ let persistentState;
27
+
28
+ const key = STATE_KEY,
29
+ value = localStorage.getItem(key);
30
+
31
+ if (value === null) {
32
+ persistentState = defaultPersistentState; ///
33
+ } else {
34
+ const persistentStateString = value; ///
35
+
36
+ persistentState = JSON.parse(persistentStateString);
37
+ }
38
+
39
+ return persistentState;
40
+ }
41
+
42
+ export function setPersistentState(persistentState) {
43
+ const persistentStateString = JSON.stringify(persistentState),
44
+ key = STATE_KEY,
45
+ value = persistentStateString; ///
46
+
47
+ localStorage.setItem(key, value);
48
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ import { isFullScreen } from "../utilities/fullScreen";
4
+ import { FULLSCREENCHANGE_EVENT_TYPE } from "../eventTypes";
5
+ import { FULL_SCREEN_CHANGE_CUSTOM_EVENT_TYPE } from "../customEventTypes";
6
+
7
+ function enableFullScreen() {
8
+ this.onFullscreenchange(this.fullscreenchangeHandler);
9
+ }
10
+
11
+ function disableFullScreen() {
12
+ this.offFullscreenchange(this.fullscreenchangeHandler);
13
+ }
14
+
15
+ function exitFullScreen() {
16
+ document.exitFullscreen();
17
+ }
18
+
19
+ function requestFullScreen() {
20
+ const domElement = this.getDOMElement();
21
+
22
+ domElement.requestFullscreen()
23
+ .catch((error) => {
24
+ alert(error);
25
+ });
26
+ }
27
+
28
+ function onFullscreenchange(fullscreenchangeHandler) {
29
+ const eventType = FULLSCREENCHANGE_EVENT_TYPE,
30
+ handler = fullscreenchangeHandler; ///
31
+
32
+ this.onEvent(eventType, handler);
33
+ }
34
+
35
+ function offFullscreenchange(fullscreenchangeHandler) {
36
+ const eventType = FULLSCREENCHANGE_EVENT_TYPE,
37
+ handler = fullscreenchangeHandler; ///
38
+
39
+ this.offEvent(eventType, handler);
40
+ }
41
+
42
+ function fullscreenchangeHandler(event, element) {
43
+ const customEventType = FULL_SCREEN_CHANGE_CUSTOM_EVENT_TYPE;
44
+
45
+ this.callCustomHandlers(customEventType, event, element);
46
+ }
47
+
48
+ function onCustomFullScreenChange(fullScreenChangeCustomHandler, element) {
49
+ const customEventType = FULL_SCREEN_CHANGE_CUSTOM_EVENT_TYPE,
50
+ customHandler = fullScreenChangeCustomHandler; ///
51
+
52
+ this.onCustomEvent(customEventType, customHandler, element);
53
+ }
54
+
55
+ function offCustomFullScreenChange(fullScreenChangeCustomHandler, element) {
56
+ const customEventType = FULL_SCREEN_CHANGE_CUSTOM_EVENT_TYPE,
57
+ customHandler = fullScreenChangeCustomHandler; ///
58
+
59
+ this.offCustomEvent(customEventType, customHandler, element);
60
+ }
61
+
62
+ const fullScreenMixins = {
63
+ enableFullScreen,
64
+ disableFullScreen,
65
+ isFullScreen,
66
+ exitFullScreen,
67
+ requestFullScreen,
68
+ onFullscreenchange,
69
+ offFullscreenchange,
70
+ fullscreenchangeHandler,
71
+ onCustomFullScreenChange,
72
+ offCustomFullScreenChange
73
+ };
74
+
75
+ export default fullScreenMixins;
@@ -14,6 +14,7 @@ import { TAP_CUSTOM_EVENT_TYPE,
14
14
  DRAG_LEFT_CUSTOM_EVENT_TYPE,
15
15
  DRAG_RIGHT_CUSTOM_EVENT_TYPE,
16
16
  DRAG_START_CUSTOM_EVENT_TYPE,
17
+ DRAG_END_CUSTOM_EVENT_TYPE,
17
18
  SWIPE_UP_CUSTOM_EVENT_TYPE,
18
19
  SWIPE_DOWN_CUSTOM_EVENT_TYPE,
19
20
  SWIPE_LEFT_CUSTOM_EVENT_TYPE,
@@ -28,13 +29,15 @@ function enableTouch() {
28
29
  const tapInterval = null,
29
30
  startMagnitude = null,
30
31
  startPositions = [],
31
- movingPositions = [];
32
+ movingPositions = [],
33
+ customGesturesEnabled = true;
32
34
 
33
35
  this.updateState({
34
36
  tapInterval,
35
37
  startMagnitude,
36
38
  startPositions,
37
- movingPositions
39
+ movingPositions,
40
+ customGesturesEnabled
38
41
  });
39
42
 
40
43
  this.onMouseDown(this.mouseDownHandler);
@@ -184,6 +187,20 @@ function offCustomDragStart(dragStartCustomHandler, element) {
184
187
  this.offCustomEvent(customEventType, customHandler, element);
185
188
  }
186
189
 
190
+ function onCustomDragEnd(dragEndCustomHandler, element) {
191
+ const customEventType = DRAG_END_CUSTOM_EVENT_TYPE,
192
+ customHandler = dragEndCustomHandler; ///
193
+
194
+ this.onCustomEvent(customEventType, customHandler, element);
195
+ }
196
+
197
+ function offCustomDragEnd(dragEndCustomHandler, element) {
198
+ const customEventType = DRAG_END_CUSTOM_EVENT_TYPE,
199
+ customHandler = dragEndCustomHandler; ///
200
+
201
+ this.offCustomEvent(customEventType, customHandler, element);
202
+ }
203
+
187
204
  function onCustomSwipeUp(swipeUpCustomHandler, element) {
188
205
  const customEventType = SWIPE_UP_CUSTOM_EVENT_TYPE,
189
206
  customHandler = swipeUpCustomHandler; ///
@@ -306,6 +323,18 @@ function setStartMagnitude(startMagnitude) {
306
323
  });
307
324
  }
308
325
 
326
+ function areCustomGesturesEnabled() {
327
+ const { customGesturesEnabled } = this.getState();
328
+
329
+ return customGesturesEnabled;
330
+ }
331
+
332
+ function setCustonGesturesEnabled(customGesturesEnabled) {
333
+ this.updateState({
334
+ customGesturesEnabled
335
+ });
336
+ }
337
+
309
338
  function getStartPositions() {
310
339
  const { startPositions } = this.getState();
311
340
 
@@ -442,12 +471,16 @@ function endHandler(event, element, positionsFromEvent) {
442
471
  const startPositionsLength = startPositions.length,
443
472
  movingPositionsLength = movingPositions.length;
444
473
 
445
- if (movingPositionsLength === 0) {
446
- this.tapOrDoubleTap(event, element);
447
- } else if (startPositionsLength === 1) {
448
- this.possibleTap(event, element);
474
+ if (startPositionsLength === 1) {
475
+ if (movingPositionsLength === 0) {
476
+ this.tapOrDoubleTap(event, element);
477
+ } else {
478
+ this.dragEnd(event, element);
479
+
480
+ this.possibleTap(event, element);
449
481
 
450
- this.possibleSwipe(event, element);
482
+ this.possibleSwipe(event, element);
483
+ }
451
484
  }
452
485
  }
453
486
 
@@ -456,16 +489,10 @@ function endHandler(event, element, positionsFromEvent) {
456
489
  filterPositions(movingPositions, positions);
457
490
  }
458
491
 
459
- function tap(event, element) {
460
- const elementTarget = isElementTarget(event, element);
461
-
462
- if (!elementTarget) {
463
- return;
464
- }
465
-
492
+ function tap(event, element, top, left) {
466
493
  const customEventType = TAP_CUSTOM_EVENT_TYPE;
467
494
 
468
- this.callCustomHandlers(customEventType, event, element);
495
+ this.callCustomHandlers(customEventType, event, element, top, left); ///
469
496
  }
470
497
 
471
498
  function drag(event, element) {
@@ -499,7 +526,7 @@ function drag(event, element) {
499
526
  }
500
527
 
501
528
  if (customEventType !== null) {
502
- this.callCustomHandlers(customEventType, event, element, top, left);
529
+ this.callCustomHandlersConditionally(customEventType, event, element, top, left);
503
530
  }
504
531
  }
505
532
 
@@ -513,7 +540,7 @@ function pinch(event, element) {
513
540
  magnitude = relativeMovingPosition.getMagnitude(),
514
541
  ratio = magnitude / startMagnitude;
515
542
 
516
- this.callCustomHandlers(customEventType, event, element, ratio);
543
+ this.callCustomHandlersConditionally(customEventType, event, element, ratio);
517
544
  }
518
545
 
519
546
  function swipe(event, element, speed, direction) {
@@ -550,20 +577,31 @@ function swipe(event, element, speed, direction) {
550
577
  top = startPosition.getTop(),
551
578
  left = startPosition.getLeft();
552
579
 
553
- this.callCustomHandlers(customEventType, event, element, top, left, speed);
580
+ this.callCustomHandlersConditionally(customEventType, event, element, top, left, speed);
554
581
  }
555
582
  }
556
583
 
557
- function doubleTap(event, element) {
584
+ function doubleTap(event, element, top, left) {
558
585
  const customEventType = DOUBLE_TAP_CUSTOM_EVENT_TYPE;
559
586
 
560
- this.callCustomHandlers(customEventType, event, element);
587
+ this.callCustomHandlersConditionally(customEventType, event, element, top, left);
588
+ }
589
+
590
+ function dragEnd(event, element) {
591
+ const customEventType = DRAG_END_CUSTOM_EVENT_TYPE;
592
+
593
+ this.callCustomHandlersConditionally(customEventType, event, element);
561
594
  }
562
595
 
563
596
  function dragStart(event, element) {
564
- const customEventType = DRAG_START_CUSTOM_EVENT_TYPE;
597
+ const customEventType = DRAG_START_CUSTOM_EVENT_TYPE,
598
+ startPositions = this.getStartPositions(),
599
+ firstStartPosition = first(startPositions),
600
+ startPosition = firstStartPosition, ///
601
+ top = startPosition.getTop(),
602
+ left = startPosition.getLeft();
565
603
 
566
- this.callCustomHandlers(customEventType, event, element);
604
+ this.callCustomHandlersConditionally(customEventType, event, element, top, left);
567
605
  }
568
606
 
569
607
  function pinchStart(event, element) {
@@ -577,7 +615,7 @@ function pinchStart(event, element) {
577
615
 
578
616
  this.setStartMagnitude(startMagnitude);
579
617
 
580
- this.callCustomHandlers(customEventType, event, element);
618
+ this.callCustomHandlersConditionally(customEventType, event, element);
581
619
  }
582
620
 
583
621
  function possibleTap(event, element) {
@@ -613,6 +651,12 @@ function possibleSwipe(event, element) {
613
651
  }
614
652
 
615
653
  function tapOrDoubleTap(event, element) {
654
+ const startPositions = this.getStartPositions(),
655
+ firstStartPosition = first(startPositions),
656
+ startPosition = firstStartPosition, ///
657
+ top = startPosition.getTop(),
658
+ left = startPosition.getLeft();
659
+
616
660
  let tapInterval = this.getTapInterval();
617
661
 
618
662
  if (tapInterval !== null) {
@@ -622,7 +666,7 @@ function tapOrDoubleTap(event, element) {
622
666
 
623
667
  this.setTapInterval(tapInterval);
624
668
 
625
- this.doubleTap(event, element);
669
+ this.doubleTap(event, element, top, left);
626
670
 
627
671
  return;
628
672
  }
@@ -632,12 +676,32 @@ function tapOrDoubleTap(event, element) {
632
676
 
633
677
  this.setTapInterval(tapInterval);
634
678
 
635
- this.tap(event, element);
679
+ this.tap(event, element, top, left);
636
680
  }, TAP_DELAY);
637
681
 
638
682
  this.setTapInterval(tapInterval);
639
683
  }
640
684
 
685
+ function enableCustomGestures() {
686
+ const customGesturedEnabled = true;
687
+
688
+ this.setCustonGesturesEnabled(customGesturedEnabled);
689
+ }
690
+
691
+ function disableCustomGestures() {
692
+ const customGesturedEnabled = false;
693
+
694
+ this.setCustonGesturesEnabled(customGesturedEnabled);
695
+ }
696
+
697
+ function callCustomHandlersConditionally(customEventType, event, element, ...remainingArguments) {
698
+ const customGesturesEnabled = this.areCustomGesturesEnabled();
699
+
700
+ if (customGesturesEnabled) {
701
+ this.callCustomHandlers(customEventType, event, element, ...remainingArguments);
702
+ }
703
+ }
704
+
641
705
  const touchMixins = {
642
706
  enableTouch,
643
707
  disableTouch,
@@ -659,6 +723,8 @@ const touchMixins = {
659
723
  offCustomDragRight,
660
724
  onCustomDragStart,
661
725
  offCustomDragStart,
726
+ onCustomDragEnd,
727
+ offCustomDragEnd,
662
728
  onCustomSwipeUp,
663
729
  offCustomSwipeUp,
664
730
  onCustomSwipeDown,
@@ -679,6 +745,8 @@ const touchMixins = {
679
745
  setStartMagnitude,
680
746
  getStartPositions,
681
747
  setStartPositions,
748
+ areCustomGesturesEnabled,
749
+ setCustonGesturesEnabled,
682
750
  getMovingPositions,
683
751
  setMovingPositions,
684
752
  touchStartHandler,
@@ -695,24 +763,15 @@ const touchMixins = {
695
763
  pinch,
696
764
  swipe,
697
765
  doubleTap,
766
+ dragEnd,
698
767
  dragStart,
699
768
  pinchStart,
700
769
  possibleTap,
701
770
  possibleSwipe,
702
- tapOrDoubleTap
771
+ tapOrDoubleTap,
772
+ enableCustomGestures,
773
+ disableCustomGestures,
774
+ callCustomHandlersConditionally
703
775
  };
704
776
 
705
777
  export default touchMixins;
706
-
707
- function isElementTarget(event, element) {
708
- if (element === window) {
709
- debugger
710
- }
711
-
712
- const { target } = event,
713
- domElement = element.getDOMElement(),
714
- domElementTarget = (domElement === target),
715
- elementTarget = domElementTarget; ///
716
-
717
- return elementTarget;
718
- }
package/src/selectors.js CHANGED
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
 
3
- export const VIEW_DIV_SELECTOR = "body > div:not(.loading)"; ///
3
+ export const DIVS_SELECTOR = "body > div:not(.loading)"; ///
4
4
  export const LOADING_DIV_SELECTOR = "body > div.loading";
5
- export const VIEW_CHILD_DIVS_SELECTOR = "body > div:not(.loading) div"; ///
package/src/state.js ADDED
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+
3
+ import { isFullScreen } from "./utilities/fullScreen";
4
+ import { getPersistentState, setPersistentState } from "./localStorage";
5
+ import {PORTRAIT_ORIENTATION} from "./constants";
6
+
7
+ const orientation = null,
8
+ state = {
9
+ orientation
10
+ };
11
+
12
+ export function getViewZoom() {
13
+ stateFromPersistentState();
14
+
15
+ const fullScreen = isFullScreen(),
16
+ orientation = getOrientation();
17
+
18
+ let viewZoom;
19
+
20
+ if (fullScreen) {
21
+ ({ fullScreenViewZoom: viewZoom } = state);
22
+ } else {
23
+ ({ viewZoom } = state);
24
+ }
25
+
26
+ const orientedViewZoom = viewZoom[orientation]; ///
27
+
28
+ viewZoom = orientedViewZoom; ///
29
+
30
+ return viewZoom;
31
+ }
32
+
33
+ export function setViewZoom(viewZoom) {
34
+ stateFromPersistentState();
35
+
36
+ const fullScreen = isFullScreen(),
37
+ orientation = getOrientation();
38
+
39
+ const orientedViewZoom = viewZoom; ///
40
+
41
+ if (fullScreen) {
42
+ ({ fullScreenViewZoom: viewZoom } = state);
43
+ } else {
44
+ ({ viewZoom } = state);
45
+ }
46
+
47
+ Object.assign(viewZoom, {
48
+ [orientation]: orientedViewZoom
49
+ });
50
+
51
+ stateToPersistentState();
52
+ }
53
+
54
+ export function getMenuDivZoom() {
55
+ stateFromPersistentState();
56
+
57
+ let menuDivZoom;
58
+
59
+ ({ menuDivZoom } = state);
60
+
61
+ const { orientation } = state,
62
+ orientedMenuDivZoom = menuDivZoom[orientation]; ///
63
+
64
+ menuDivZoom = orientedMenuDivZoom; ///
65
+
66
+ return menuDivZoom;
67
+ }
68
+
69
+ export function setMenuDivZoom(menuDivZoom) {
70
+ stateFromPersistentState();
71
+
72
+ const { orientation } = state,
73
+ orientedMenuDivZoom = menuDivZoom; ///
74
+
75
+ ({ menuDivZoom } = state);
76
+
77
+ Object.assign(menuDivZoom, {
78
+ [orientation]: orientedMenuDivZoom
79
+ });
80
+
81
+ stateToPersistentState();
82
+ }
83
+
84
+ export function getOrientation() {
85
+ const { orientation } = state;
86
+
87
+ return orientation;
88
+ }
89
+
90
+ export function setOrientation(orientation) {
91
+ Object.assign(state, {
92
+ orientation
93
+ });
94
+ }
95
+
96
+ export function areColoursInverted() {
97
+ stateFromPersistentState();
98
+
99
+ const { coloursInverted } = state;
100
+
101
+ return coloursInverted;
102
+ }
103
+
104
+ export function setColoursInverted(coloursInverted) {
105
+ stateFromPersistentState();
106
+
107
+ Object.assign(state, {
108
+ coloursInverted
109
+ });
110
+
111
+ stateToPersistentState();
112
+ }
113
+
114
+ function stateToPersistentState() {
115
+ const { viewZoom, menuDivZoom, fullScreenViewZoom, coloursInverted } = state,
116
+ persistentState = {
117
+ viewZoom,
118
+ menuDivZoom,
119
+ fullScreenViewZoom,
120
+ coloursInverted
121
+ };
122
+
123
+ setPersistentState(persistentState);
124
+ }
125
+
126
+ function stateFromPersistentState() {
127
+ const persistentState = getPersistentState();
128
+
129
+ Object.assign(state, persistentState);
130
+ }
package/src/styles.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ export const svgFill = "#fff";
4
+ export const buttonSize = "64px";
5
+ export const spanColour = "#fff";
6
+ export const borderWidth = "4px";
7
+ export const borderRadius = "8px"
8
+ export const borderColour = "#fff";
9
+ export const checkboxSize = "48px";
10
+ export const spanFontSize = checkboxSize; ///
11
+ export const buttonPadding = "8px";
12
+ export const buttonsDivGap = "32px";
13
+ export const menuDivPadding = "64px";
14
+ export const checkboxDivGap = "32px";
15
+ export const checkboxesDivGap = "48px";
16
+ export const backgroundColour = "#222";
17
+ export const checkboxBackgroundColour = "#000";
18
+ export const fontSizeButtonBorderColour = "#fff";
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- import { SINGLE_SPACE } from "../constants";
4
-
5
3
  export function elementsFromDOMElements(domElements, Element) {
6
4
  const elements = domElements.map((domElement) => {
7
5
  const element = elementFromDOMElement(domElement, Element);
@@ -13,22 +11,14 @@ export function elementsFromDOMElements(domElements, Element) {
13
11
  }
14
12
 
15
13
  export function elementFromDOMElement(domElement, Element) {
16
- const element = <Element/>;
14
+ const element =
17
15
 
18
- const { domElement: temporaryDOMElement } = element,
19
- { className: classNamesString } = temporaryDOMElement,
20
- classNames = classNamesString.split(SINGLE_SPACE);
16
+ <Element/>
21
17
 
22
- const { classList } = domElement,
23
- { childNodes } = temporaryDOMElement;
18
+ ,
19
+ className = classNameFromElement(element);
24
20
 
25
- childNodes.forEach((childNode) => {
26
- domElement.appendChild(childNode);
27
- });
28
-
29
- classNames.forEach((className) => {
30
- classList.add(className);
31
- });
21
+ addClassNameToDOMElement(domElement, className)
32
22
 
33
23
  element.domElement = domElement; ///
34
24
 
@@ -36,3 +26,16 @@ export function elementFromDOMElement(domElement, Element) {
36
26
 
37
27
  return element;
38
28
  }
29
+
30
+ function classNameFromElement(element) {
31
+ const domElement = element.getDOMElement(),
32
+ { className } = domElement;
33
+
34
+ return className;
35
+ }
36
+
37
+ function addClassNameToDOMElement(domElement, className) {
38
+ const { classList } = domElement;
39
+
40
+ classList.add(className);
41
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ export function isFullScreen() {
4
+ const { fullscreenElement } = document,
5
+ fullScreen =(fullscreenElement !== null);
6
+
7
+ return fullScreen;
8
+ }