highmark-cli 0.0.144 → 0.0.146

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.
@@ -56,14 +56,16 @@ export default function createMethods(scheduler, model, view) {
56
56
 
57
57
  function exitFullScreen() {
58
58
  view.exitFullScreen();
59
-
60
- view.updateFullScreenCheckboxDiv();
61
59
  }
62
60
 
63
61
  function enterFullScreen() {
64
- view.enterFullScreen(() => {
65
- view.updateFullScreenCheckboxDiv();
66
- });
62
+ view.enterFullScreen();
63
+ }
64
+
65
+ function updateFullScreen() {
66
+ view.closeMenu();
67
+
68
+ view.updateFullScreenCheckboxDiv();
67
69
  }
68
70
 
69
71
  function restoreNativeGestures() {
@@ -96,6 +98,7 @@ export default function createMethods(scheduler, model, view) {
96
98
  revertColours,
97
99
  exitFullScreen,
98
100
  enterFullScreen,
101
+ updateFullScreen,
99
102
  restoreNativeGestures,
100
103
  suppressNativeGestures
101
104
  });
@@ -16,11 +16,10 @@ function exitFullScreen() {
16
16
  document.exitFullscreen();
17
17
  }
18
18
 
19
- function requestFullScreen(callback) {
19
+ function requestFullScreen() {
20
20
  const domElement = this.getDOMElement();
21
21
 
22
22
  domElement.requestFullscreen()
23
- .then(callback)
24
23
  .catch(alert);
25
24
  }
26
25
 
package/src/selectors.js CHANGED
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
 
3
+ export const DIV_SELECTOR = "div";
3
4
  export const DIVS_SELECTOR = "body > div:not(.loading)"; ///
4
5
  export const LOADING_DIV_SELECTOR = "body > div.loading";
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ import { DIV_SELECTOR } from "../selectors";
4
+
3
5
  export function elementsFromDOMElements(domElements, Element) {
4
6
  const elements = domElements.map((domElement) => {
5
7
  const element = elementFromDOMElement(domElement, Element);
@@ -27,6 +29,29 @@ export function elementFromDOMElement(domElement, Element) {
27
29
  return element;
28
30
  }
29
31
 
32
+ export function findDivByAnchorId(anchorId) {
33
+ const selector = DIV_SELECTOR,
34
+ anchorDOMElement = findAnchorDOMElement(anchorId),
35
+ divDOMElement = anchorDOMElement.closest(selector);
36
+
37
+ const { __element__: div } = divDOMElement;
38
+
39
+ return div;
40
+ }
41
+
42
+ export function scrollToAnchor(anchorId) {
43
+ const anchorDOMElement = findAnchorDOMElement(anchorId);
44
+
45
+ anchorDOMElement.scrollIntoView();
46
+ }
47
+
48
+ function findAnchorDOMElement(anchorId) {
49
+ const selector = `a#${anchorId}`,
50
+ anchorDOMElement = document.querySelector(selector);
51
+
52
+ return anchorDOMElement;
53
+ }
54
+
30
55
  function classNameFromElement(element) {
31
56
  const domElement = element.getDOMElement(),
32
57
  { className } = domElement;
@@ -38,4 +63,4 @@ function addClassNameToDOMElement(domElement, className) {
38
63
  const { classList } = domElement;
39
64
 
40
65
  classList.add(className);
41
- }
66
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ import { HASH, EMPTY_STRING } from "../constants";
4
+
5
+ export function resetFragment() {
6
+ let { href } = location;
7
+
8
+ const index = href.indexOf(HASH);
9
+
10
+ if (index === -1) {
11
+ return;
12
+ }
13
+
14
+ const start = 0,
15
+ end = index; ///
16
+
17
+ href = href.substring(start, end); ///
18
+
19
+ history.replaceState({}, EMPTY_STRING, href);
20
+ }
@@ -3,7 +3,7 @@
3
3
  import withStyle from "easy-with-style"; ///
4
4
 
5
5
  import { window } from "easy";
6
- import { keyCodes, arrayUtilities } from "necessary";
6
+ import { keyCodes } from "necessary";
7
7
 
8
8
  import Div from "../div";
9
9
  import Element from "../element";
@@ -11,12 +11,13 @@ import touchMixins from "../../mixins/touch";
11
11
  import fullScreenMixins from "../../mixins/fullsrean";
12
12
 
13
13
  import { isFullScreen } from "../../utilities/fullScreen";
14
+ import { resetFragment } from "../../utilities/fragment";
14
15
  import { elementsFromDOMElements } from "../../utilities/element";
16
+ import { scrollToAnchor, findDivByAnchorId } from "../../utilities/element";
15
17
  import { getOverlayZoom as getZoom, areColoursInverted, areNativeGesturesRestored } from "../../state";
16
18
  import { SCROLL_DELAY, UP_DIRECTION, DECELERATION, DOWN_DIRECTION, OPEN_MENU_TAP_AREA_HEIGHT } from "../../constants";
17
19
 
18
- const { first } = arrayUtilities,
19
- { ENTER_KEY_CODE,
20
+ const { ENTER_KEY_CODE,
20
21
  ESCAPE_KEY_CODE,
21
22
  BACKSPACE_KEY_CODE,
22
23
  ARROW_UP_KEY_CODE,
@@ -26,7 +27,7 @@ const { first } = arrayUtilities,
26
27
 
27
28
  class OverlayDiv extends Element {
28
29
  fullScreenChangeCustomHandler = (event, element) => {
29
- controller.closeMenu();
30
+ controller.updateFullScreen();
30
31
 
31
32
  this.updateOverlayZoom();
32
33
  }
@@ -140,7 +141,13 @@ class OverlayDiv extends Element {
140
141
  }
141
142
 
142
143
  case ESCAPE_KEY_CODE: {
143
- controller.exitFullScreen();
144
+ const fullScreen = isFullScreen();
145
+
146
+ if (fullScreen) {
147
+ controller.exitFullScreen();
148
+ }
149
+
150
+ controller.closeMenu();
144
151
 
145
152
  break;
146
153
  }
@@ -159,6 +166,26 @@ class OverlayDiv extends Element {
159
166
  }
160
167
  }
161
168
 
169
+ scrollToAnchor(anchorId) {
170
+ let div;
171
+
172
+ div = findDivByAnchorId(anchorId);
173
+
174
+ const nextDiv = div; ///
175
+
176
+ div = this.findDiv();
177
+
178
+ const previousDiv = div; ///
179
+
180
+ const divs = this.getDivs(),
181
+ nextIndex = divs.indexOf(nextDiv), ///
182
+ previousIndex = divs.indexOf(previousDiv); ///
183
+
184
+ this.showNextDiv(nextIndex, previousIndex, () => {
185
+ scrollToAnchor(anchorId);
186
+ });
187
+ }
188
+
162
189
  scrollToTop() {
163
190
  const scrollTop = 0;
164
191
 
@@ -211,8 +238,8 @@ class OverlayDiv extends Element {
211
238
  this.setInterval(interval);
212
239
  }
213
240
 
214
- enterFullScreen(callback) {
215
- this.requestFullScreen(callback);
241
+ enterFullScreen() {
242
+ this.requestFullScreen();
216
243
  }
217
244
 
218
245
  updateOverlayZoom() {
@@ -228,20 +255,18 @@ class OverlayDiv extends Element {
228
255
  coloursInverted ?
229
256
  this.addClass("inverted-colours") :
230
257
  this.removeClass("inverted-colours");
231
-
232
- this.updateOverlayZoom();
233
258
  }
234
259
 
235
260
  updateNativeGestures() {
236
- // const nativeGesturesRestored = areNativeGesturesRestored();
237
- //
238
- // nativeGesturesRestored ?
239
- // this.addClass("native-gestures") :
240
- // this.removeClass("native-gestures");
241
- //
242
- // nativeGesturesRestored ?
243
- // this.disableCustomGestures() :
244
- // this.enableCustomGestures();
261
+ const nativeGesturesRestored = areNativeGesturesRestored();
262
+
263
+ nativeGesturesRestored ?
264
+ this.addClass("native-gestures") :
265
+ this.removeClass("native-gestures");
266
+
267
+ nativeGesturesRestored ?
268
+ this.disableCustomGestures() :
269
+ this.enableCustomGestures();
245
270
  }
246
271
 
247
272
  areNativeGesturesRestored() {
@@ -282,53 +307,65 @@ class OverlayDiv extends Element {
282
307
  showLastDiv() {
283
308
  const div = this.findDiv(),
284
309
  divs = this.getDivs(),
285
- index = divs.indexOf(div),
286
310
  divsLength = divs.length,
311
+ index = (div === null) ?
312
+ -1 :
313
+ divs.indexOf(div),
287
314
  nextIndex = divsLength - 1,
288
- previousIndex = (index === -1) ?
289
- nextIndex : ///
290
- index; ///
315
+ previousIndex = index; ///
316
+
317
+ if (nextIndex === previousIndex) {
318
+ return;
319
+ }
291
320
 
292
321
  this.showNextDiv(nextIndex, previousIndex);
293
322
  }
294
323
 
295
- showNextDiv(nextIndex, previousIndex) {
296
- const zoom = getZoom(),
324
+ showFirstDiv() {
325
+ const div = this.findDiv(),
297
326
  divs = this.getDivs(),
298
- nextDiv = divs[nextIndex],
299
- previousDiv = divs[previousIndex];
300
-
301
- this.stopScrolling();
327
+ index = (div === null) ?
328
+ -1 :
329
+ divs.indexOf(div),
330
+ nextIndex = 0,
331
+ previousIndex = index; ///
302
332
 
303
- this.scrollToTop();
333
+ if (nextIndex === previousIndex) {
334
+ return;
335
+ }
304
336
 
305
- this.remove(previousDiv);
337
+ this.showNextDiv(nextIndex, previousIndex);
338
+ }
306
339
 
307
- this.add(nextDiv);
340
+ showNextDiv(nextIndex, previousIndex, done = () => {}) {
341
+ resetFragment();
308
342
 
309
- nextDiv.zoom(zoom);
343
+ const divs = this.getDivs();
310
344
 
311
- setTimeout(() => {
312
- const backgroundColour = nextDiv.getBackgroundColour();
345
+ if (previousIndex !== -1) {
346
+ const previousDiv = divs[previousIndex];
313
347
 
314
- this.setBackgroundColour(backgroundColour);
315
- }, 0);
316
- }
348
+ previousDiv.hide();
349
+ }
317
350
 
318
- showFirstDiv() {
319
351
  const zoom = getZoom(),
320
- divs = this.getDivs(),
321
- firstDiv = first(divs);
352
+ nextDiv = divs[nextIndex];
322
353
 
323
- this.add(firstDiv);
354
+ this.stopScrolling();
324
355
 
325
- firstDiv.zoom(zoom);
356
+ this.scrollToTop();
326
357
 
327
- setTimeout(() => {
328
- const backgroundColour = firstDiv.getBackgroundColour();
358
+ nextDiv.zoom(zoom);
359
+
360
+ nextDiv.show();
361
+
362
+ defer(() => {
363
+ const backgroundColour = nextDiv.getBackgroundColour();
329
364
 
330
365
  this.setBackgroundColour(backgroundColour);
331
- }, 0);
366
+
367
+ done();
368
+ });
332
369
  }
333
370
 
334
371
  setBackgroundColour(backgroundColour) {
@@ -343,28 +380,23 @@ class OverlayDiv extends Element {
343
380
  findDiv() {
344
381
  const divs = this.getDivs(),
345
382
  div = divs.find((div) => {
346
- const added = div.isAdded();
383
+ const showing = div.isShowing();
347
384
 
348
- if (added) {
385
+ if (showing) {
349
386
  return true;
350
387
  }
351
- });
388
+ }) || null;
352
389
 
353
390
  return div;
354
391
  }
355
392
 
356
393
  getDivs() {
357
- const { divs } = this.getState();
394
+ const childElements = this.getChildElements(),
395
+ divs = childElements; ///
358
396
 
359
397
  return divs;
360
398
  }
361
399
 
362
- setDivs(divs) {
363
- this.updateState({
364
- divs
365
- });
366
- }
367
-
368
400
  getInterval() {
369
401
  const { interval } = this.getState();
370
402
 
@@ -402,13 +434,11 @@ class OverlayDiv extends Element {
402
434
  }
403
435
 
404
436
  setInitialState() {
405
- const divs = this.createDivs(),
406
- interval = null,
437
+ const interval = null,
407
438
  startZoom = null,
408
439
  startScrollTop = null;
409
440
 
410
441
  this.setState({
411
- divs,
412
442
  interval,
413
443
  startZoom,
414
444
  startScrollTop
@@ -459,21 +489,28 @@ class OverlayDiv extends Element {
459
489
  window.offKeyDown(this.keyDownHandler);
460
490
  }
461
491
 
462
- createDivs() {
492
+ childElements() {
463
493
  const { divDOMElements } = this.properties,
464
- divs = elementsFromDOMElements(divDOMElements, Div);
494
+ divs = elementsFromDOMElements(divDOMElements, Div),
495
+ childElements = [
496
+ ...divs
497
+ ];
465
498
 
466
- return divs;
499
+ return childElements;
467
500
  }
468
501
 
469
502
  parentContext() {
470
- const exitFullScreen = this.exitFullScreen.bind(this),
503
+ const showFirstDiv = this.showFirstDiv.bind(this),
504
+ scrollToAnchor = this.scrollToAnchor.bind(this),
505
+ exitFullScreen = this.exitFullScreen.bind(this),
471
506
  enterFullScreen = this.enterFullScreen.bind(this),
472
507
  updateOverlayZoom = this.updateOverlayZoom.bind(this),
473
508
  updateOverlayColours = this.updateOverlayColours.bind(this),
474
509
  updateNativeGestures = this.updateNativeGestures.bind(this);
475
510
 
476
511
  return ({
512
+ showFirstDiv,
513
+ scrollToAnchor,
477
514
  exitFullScreen,
478
515
  enterFullScreen,
479
516
  updateOverlayZoom,
@@ -486,8 +523,6 @@ class OverlayDiv extends Element {
486
523
  this.assignContext();
487
524
 
488
525
  this.setInitialState();
489
-
490
- this.showFirstDiv();
491
526
  }
492
527
 
493
528
  static tagName = "div";
@@ -522,3 +557,7 @@ export default withStyle(OverlayDiv)`
522
557
  }
523
558
 
524
559
  `;
560
+
561
+ function defer(func) {
562
+ setTimeout(func, 0);
563
+ }
package/src/view/div.js CHANGED
@@ -13,14 +13,6 @@ class Div extends Element {
13
13
  return backgroundColour;
14
14
  }
15
15
 
16
- isAdded() {
17
- const domElement = this.getDOMElement(),
18
- { parentNode } = domElement,
19
- added = (parentNode !== null);
20
-
21
- return added;
22
- }
23
-
24
16
  zoom(zoom) {
25
17
  const zoomRatio = 100 / zoom,
26
18
  width = `${zoomRatio}%`,
@@ -36,6 +28,14 @@ class Div extends Element {
36
28
  this.css(css);
37
29
  }
38
30
 
31
+ didMount() {
32
+ this.hide();
33
+ }
34
+
35
+ willUnmount() {
36
+ ///
37
+ }
38
+
39
39
  static tagName = "div";
40
40
  }
41
41
 
package/src/view.js CHANGED
@@ -14,8 +14,8 @@ class View extends Element {
14
14
  }
15
15
 
16
16
  didMount() {
17
- this.updateMenuZoom();
18
- this.updateOverlayZoom();
17
+ this.show();
18
+
19
19
  this.updateOverlayColours();
20
20
  this.updateNativeGestures();
21
21
  this.updateFullScreenCheckboxDiv();
@@ -41,8 +41,6 @@ class View extends Element {
41
41
 
42
42
  initialise() {
43
43
  this.assignContext();
44
-
45
- this.show();
46
44
  }
47
45
 
48
46
  static tagName = "div";